Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

stop-polaris not stopping the web server over 8080 or any port it's started with. #198

Open
harikanth64 opened this issue Oct 1, 2019 · 6 comments

Comments

@harikanth64
Copy link

harikanth64 commented Oct 1, 2019

Polaris Bug Report

After running Stop-Polaris and when try to re-start the (start-Polaris) it will throw an error.

Description of the bug

Stop-Polaris is not stopping web server on whichever port its started with. I get a below when try to run Start-polaris

Exception` calling "Start" with "0" argument(s): "Failed to listen on prefix 'http://localhost:8080/' because it conflicts with an existing registration on the machine." At C:\Users\harikant\Documents\WindowsPowerShell\Modules\Polaris\0.2.0\lib\Polaris.Class.ps1:316 char:9 + $this.Listener.Start() + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : HttpListenerException

A clear and concise description of what the bug is.

Steps to reproduce

Example when you run the below code

New-PolarisGetRoute -Path "/helloworld" -Scriptblock {
    $Response.Send('Hello World!')
}

Start-Polaris -Port 8080

And run Stop-Polaris and again try to start-polaris command it thows the above error.

Expected behavior

To be able to stop and start the Polaris server without any errors.

Version Information


PSVersion : 5.1.17134.858
PSEdition : Desktop
PSCompatibleVersions : {1.0, 2.0, 3.0, 4.0...}
BuildVersion : 10.0.17134.858
CLRVersion : 4.0.30319.42000
WSManStackVersion : 3.0
PSRemotingProtocolVersion : 2.3
SerializationVersion : 1.1.0.1

NameVersion
Polaris0.2.0
PSVersionPSEditionPSCompatibleVersionsBuildVersionCLRVersionWSManStackVersionPSRemotingProtocolVersionSerializationVersion
5.1.17134.858DesktopSystem.Version[]10.0.17134.8584.0.30319.420003.02.31.1.0.1
@harikanth64
Copy link
Author

Any update on this issue/bug?

@Tiberriver256
Copy link
Contributor

Hi Harikanth, would you be able to take a look at the PR?

@harikanth64
Copy link
Author

harikanth64 commented Oct 31, 2019 via email

@Tiberriver256
Copy link
Contributor

If you want to try the code in PR #200 it should let you call Start-Polaris multiple times without any negative effects.

To answer your question though you can either use Remove-PolarisRoute -Path '/home' -Method POST and then re-add the route with New-PolarisPostRoute -Path '/home' -ScriptBlock ... or you can add the -Force parameter to New-PolarisPostRoute to tell it to overwrite an existing route.

@harikanth64
Copy link
Author

@Tiberriver256 Thanks so much for your answers.
It is working as expected now. This question can be closed.

Tiberriver256 added a commit that referenced this issue Nov 15, 2019
* Fix for #198 start-polaris throwing error

* Getting rid of the odd beforeAll

* Server shouldn't be stopped

* Restored accidentally removed test
@ghost
Copy link

ghost commented Feb 18, 2020

I used the code from PR #200 but had to remove $Hostname from
$this.InitListener($Port, $Https, $Auth, $Hostname) (line 267 and 276) in order to make it work

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants