1

我在将客户端连接到 socket.io 服务器时遇到问题。我有以下代码:

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);
    }

我正在使用 websocket-uri

http://127.0.0.1:5116/

当我在浏览器中打开该地址时,它会显示正确的 socket.io socketserver。

在连接到此 socket.io 服务器时,我收到以下错误:

Error getting handsake from Socket.IO host instance: 
Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.

所以这是一个http错误(400)错误请求。但为什么?我能做些什么?我刚刚尝试了以下代码(来自其他问题的用户的解决方案):

 System.Net.WebRequest.DefaultWebProxy = null;

但这对我不起作用。

4

1 回答 1

2

I fixed this error by myself. It was very simple. The handshake of the socket.io version 1.0.x isn't the same as in version 0.9.x. And SocketIO4Net only working with socket.io version 0.9.x. I downgraded to version 0.9.17 and now it's working perfectly :)

于 2014-06-15T11:43:11.410 回答