SocketIO4Net握手错误

时间:2014-06-14 12:08:06

标签: sockets http socket.io socketio4net

我遇到了客户端连接到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;

但这对我没用。

1 个答案:

答案 0 :(得分:2)

我自己修正了这个错误。 这很简单。 socket.io版本1.0.x的握手与版本0.9.x中的握手不同。而SocketIO4Net仅适用于socket.io版本0.9.x.我降级到版本0.9.17,现在它完美地工作:)

相关问题