Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# socketio4net初始化握手时出错_C#_Sockets_Mono_Bitcoin_Socketio4net - Fatal编程技术网

C# socketio4net初始化握手时出错

C# socketio4net初始化握手时出错,c#,sockets,mono,bitcoin,socketio4net,C#,Sockets,Mono,Bitcoin,Socketio4net,我正在OSX上使用Xamarin(mono 3.2.5)创建一个连接到blockchain.info websocket流的C#console应用程序。我已经包括了NuGet的socketio4net库,并认为我正确地遵循了规范,但是我对socket.io连接一般来说有点陌生,所以请纠正我的错误。调用下面的socket.Connect()方法后,我立即收到一个错误 我创建了一些事件处理程序,如下所示: static void SocketOpened(object sender, EventAr

我正在OSX上使用Xamarin(mono 3.2.5)创建一个连接到blockchain.info websocket流的C#console应用程序。我已经包括了NuGet的socketio4net库,并认为我正确地遵循了规范,但是我对socket.io连接一般来说有点陌生,所以请纠正我的错误。调用下面的socket.Connect()方法后,我立即收到一个错误

我创建了一些事件处理程序,如下所示:

static void SocketOpened(object sender, EventArgs e) 
{
    Console.WriteLine ("opened event handler");
    Console.WriteLine (e.ToString());
}

static void SocketError(object sender, SocketIOClient.ErrorEventArgs e) 
{
    Console.WriteLine ("error event handler");
    Console.WriteLine (e.Message);
}

static void SocketMessage(object sender, MessageEventArgs e) 
{
    Console.WriteLine ("message event handler");
    Console.WriteLine (e.Message);
}
我的代码如下:

var socket = new Client (@"ws://ws.blockchain.info:8335/inv");
socket.Opened += SocketOpened;
socket.Error += SocketError;
socket.Message += SocketMessage;

socket.Connect ();
Console.WriteLine ("handshake: " + socket.HandShake.ErrorMessage);

socket.On("connect", (fn) => {
    Console.WriteLine("On.connect msg: " + fn.MessageText);
});

socket.On ("open", (fn) => {
    Console.WriteLine("On.open msg: " + fn.MessageText);
});
我的控制台输出来自:

error event handler
Error initializing handshake with ws://ws.blockchain.info:8335/inv
handshake: Error getting handsake from Socket.IO host instance: An error occurred performing a WebClient request.
我做错了什么?区块链API文档在这里:我已经尝试了它们指定的两个URL。忽略URL中的端口号会产生另一个错误。它不是“执行WebClient请求时出错”,而是查找套接字服务器的本地路径,这显然是错误的


如果能得到经验丰富的程序员的任何帮助,我将不胜感激。

我也面临同样的问题,就我而言,这是因为办公室默认的互联网连接必须通过代理

只需使用下面的代码将代理设置为“无”,即可解决我的问题


System.Net.WebRequest.DefaultWebProxy=null

我也有同样的问题,你解决了吗?@greenyedandy你解决了吗?