jchristn/WatsonWebsocket

I cannot make a connection using Ngrok.

Closed this issue · 2 comments

I am Japanese and this text is created using deepL.
Sorry if the text is incomprehensible.
I am currently trying to create a multiplayer server using ngrok.
I used wscat and tried to connect through ngrok and got a 400 error and could not connect.
It was possible to connect without ngrok.
The OS I am using is Windows 11 and the dotnet version I am using is 7.0.
The code is as follows.

using WatsonWebsocket;

WatsonWsServer server = new(port: 3000);
server.ClientConnected += (s, e)
    => Console.WriteLine($"connected: {e.Client.Port}");

server.ClientDisconnected += (s, e)
    => Console.WriteLine($"disconnected: {e.Client.Port}");

Console.WriteLine("Start");
server.Start();

await server;

Hi @KurisuJuha did you try using the client project or using the browser locally? Is the machine that is unable to connect outside of your local network? Also, you shouldn't use the default constructor; use this one instead:

public WatsonWsServer(string hostname = "localhost", int port = 9000, bool ssl = false)

I suspect that the default constructor is not initializing things correctly.

Note that if you have issues connecting from machines other than localhost, refer to the README on steps to take: https://github.com/jchristn/WatsonWebsocket/blob/master/README.md

Closed due to inactivity.