SocketIO4Net握手错误 [英] SocketIO4Net Handshake Error

查看:74
本文介绍了SocketIO4Net握手错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户端与socket.io服务器的连接出现问题. 我有以下代码:

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

我正在使用websocket-uri

I'm using the websocket-uri

http://127.0.0.1:5116/

当我在浏览器中打开该地址时,它向我显示了正确的socket.io套接字服务器.

When I open that address in browser, it shows me the right socket.io socketserver.

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

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.

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

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;

但这对我不起作用.

推荐答案

我自己修复了此错误. 这很简单. socket.io版本1.0.x的握手与版本0.9.x中的握手不同.并且SocketIO4Net仅可用于socket.io 0.9.x版.我降级到0.9.17版本,现在可以正常使用了:)

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 :)

这篇关于SocketIO4Net握手错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆