I've got a problem with the connection of a client to a socket.io server. I have following code:
private Client _Client;
private void Initialize(string websocket)
{
try
{
this._Client = new Client(websocket);
this._Client.Connect();
if (!this._Client.IsConnected) throw new Exception("Connection to websocket wasn't successfully: " + this._Client.HandShake.ErrorMessage);
}
catch (Exception ex)
{
Logging.Write("Fehler bei der SocketIO-Connection: " + ex.Message);
Logging.WriteLine("incomplete!", ConsoleColor.Red);
return;
}
Logging.WriteLine("completed!", ConsoleColor.Green);
}
I'm using the websocket-uri
http://127.0.0.1:5116/
When I open that address in browser, it shows me the right socket.io socketserver.
At connection to this socket.io server I get the following error:
Error getting handsake from Socket.IO host instance:
Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.
So it is a http error (400) bad request. But why? What can I do? I just tried the following code (a solution from a user from a other question):
System.Net.WebRequest.DefaultWebProxy = null;
But that didn't work for me.