jchristn / WatsonWebsocket

A simple C# async websocket server and client for reliable transmission and receipt of data
MIT License
277 stars 53 forks source link

I cannot make a connection using Ngrok. #120

Closed KurisuJuha closed 1 year ago

KurisuJuha commented 1 year ago

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;
jchristn commented 1 year ago

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

jchristn commented 1 year ago

Closed due to inactivity.