jchristn/WatsonWebsocket

Connecting from outside localhost

Closed this issue · 31 comments

Hello,
i'm desesperately trying to make the server listening to other than localhost to ease my debug from outside.
Unfortunately, after reading your part : 'Listening from outside localhost' and hours of trying I didnt end up to a good result.
I'm using windows 10 and Visual Studio.
I have tried the multiple hostname list constructor and got 'bad URI format error'
I tried with only my public ip, another error on starting the server
Tried to edit my windows host file to point this ip to localhost, same error
Tried to make the '*' wild card, the server runs but my mate cannot connect
Opened the port on my internet provider, nothing
Created a firewall rules : nothing.

I don't really know what I could do next, if you have any idea, I'm listening.

Thank you very much

I also add that visual studio is run into administrator mode.

Hi @ange-black69 did you set up your urlacls? The bottom two sections of this doc might be helpful: https://github.com/jchristn/WatsonWebserver/wiki/Using-SSL-on-Windows

Note: this doc is regarding use of SSL, but URL ACLs are required in either case.

image

Hello @jchristn thanks for the answer.
I have added urlacl, here is what the netsh http show urlacl is :

image

Then as it's a french version of windows, the 'everyone' is not recognized correctly, so I made 'user=mike'.

I havent configured ssl certificate for now, however I see your link and it was what I have already done

Here is the way I start the server :
image

My router had the port open too.
However, when the server is up and running and try a tool like https://www.yougetsignal.com/tools/open-ports/ my port is shown closed.
I have disabled my firewall temporary too and neither.
So I suspect that the server isnt listening properly.

Did I miss anything?
Thanks for your help

Hi @ange-black69 can you connect to it from within the same machine? Are you running as administrator?

Edit: I just saw your note about running as administrator.

hello @jchristn
yes I could connect using this settings on my same machine.
I'm running visual studio 2022 as adminsitrator also and also tried when building the exe and executing directly as administrator and nothing.
Do you have any clue?
I'm building a online game and it will be way more handy to debug the server if I could let others people connect to my machine and debug from there.
Thank you for your help

Hi @ange-black69 good to know connections work on the same machine. Have you tried from another machine on the same network? If it isn't allowed through, it's either 1) firewall or 2) URL ACLs. Also I notice you have URL ACLs for both * and +, you may want to delete the one for * and just use +, and try using 0.0.0.0 in your constructor.

Hello @jchristn
I have deleted all my url acl and only added the '+' and then added '0.0.0.0' on the constructor and I got a exception thrown when starting the ws server : [HttpListenerException] : this request is not supported
image
image

If you have any clue?
Thanks per advance

Could you try setting the constructor back to +, and try running outside of the Visual Studio debugger? I'm wondering if VS debugger uses its own implementation for certain underlying kernel services (such as http.sys).

thanks for the really quick repply!
Indeed, it's working on localhost!
However, my port (2712) is still seen as closed from outside, despite opening it in my router...
That means the application is not willing to communicate to outside.
Any idea?
Thanks :)

Another note : I have build the application, and executed it standalone as administrator, disabled my firewall too to be sure, and nothing, the server is unreachable

Hi, can it be reached by another machine on the same network? I have JS test code in the README that you can use on another machine's browser.

Ok so I have tried with the android version of my game on my phone on the same network and inputing the local ip where the server machine is and no I cannot connect

Wow, this is strange. To make sure I understand, the server is Windows 10, you're running as administrator, using + in the constructor, are able to access the service from within the same system, but not from an external system that is on the same network. Give me a moment.

Another note : when deploying the app to a linux vps, on a test server for example, and filing the machine's ip on the constructor, everything works fine.
The issue is only on windows.

Wow, this is strange. To make sure I understand, the server is Windows 10, you're running as administrator, using + in the constructor, are able to access the service from within the same system, but not from an external system that is on the same network. Give me a moment.

yes this is exactly this

Hi @ange-black69 what version of the library are you using? Something must be blocking the connection, I just tested using the Test.Server project on one machine and the browser on another, and with the right firewall rule allowing the connection, it went through just fine. Would you be willing to test using the Test.Server project (from v2.3.2.6) and a browser on another machine? I'm going to paste my results here (from this machine), and then edit the comment momentarily from the other machine.

From the client:
image

From the server:
image

image

Note: I use a range of ports, because I never know which I'm going to pick, but I stay within that range. You mentioned your firewall was disabled, so it should be out of the equation.

I'm running v2.3.2.1
I will try to do what you mentionned above!
Thank you in advance for your time and patience.

@ange-black69 happy to help, let's get it working :)

@jchristn
alright so after doing a dotnet build, then executing :
image

It means : access denied.

Can you try running in Command Prompt instead of PowerShell, and make sure it's running as administrator?

image
ok so tried with port 9000 and port 2712
and nothing.
Really hoping to find the solution :)

image
Ok so I have run this as adminsitrator and it runs fine, lets try on client

image
Ok so I just wanted to test on localhost and it worked, now i'm aiming to see this on another machine on same network

@jchristn
I havent any other working machine actually, is there any other method we could ?
thanks

Hi @ange-black69 if you're running HTTP you may also want to try deleting the URL ACL. I may have misspoke when I recommended having that. I had to delete it from mine.

So it looks like the test server app is working locally, that's a good step. You don't have another computer to test with? Otherwise it's really hard (even with a virtual machine) to make sure network traffic comes in through the network interface.

@jchristn
Alright so, I have deleted all url acl related to the 2712 port.
Unfortunately no, I havent any other pc appart from my android phone.
I tried to access the console from there but it cannot let me send the websocket as it's a clear text / unsecure conneection...
I will try to test again with my game on my phone and try if I can connect

alright so @jchristn unfortunately I cannot connect from my phone on SAME network and having the url acl deleted...
I cannot lie that i'm a little disapointed and sad...
I probably need another computer to test the connection but having my game implementing the websocket server and having my phone is a good client test..
If you wish to add me on discord : Alfanatique(aka Mike D)#6515
and help me further on that, I will be glad...
Thank you again for your help and consideration.

Got it, but can it connect with the URL ACL in place? I'll add you on Discord.

hi @jchristn
With and without the url acl, the localhost connection is working fine.
For the discord, if you have a discord name I could add you directly.
greetings

Same problem.
I notice that specifying the ip address, client connect to ws://, while server listen to http://.
The exception I receive is thrown by AddAllPrefixed() instead of AddPrefixCore.
The server is inside a vm in another pc and I can access to its docker container or other services from my pc.
The server starts without problem, so the client, but the server doesn't receive any connection and the client results not connected (Connected = false after Start()).