I'm using Xamarin(mono 3.2.5) on OSX to create a C# console app that connects to the blockchain.info websocket stream. I've included the socketio4net library from NuGet and thought I followed the specs correctly, but I'm a bit new to socket.io connections in general, so please correct me on what I'm doing wrong. I get an error immediately after calling the socket.Connect() method below.
I have created a few event handlers like so:
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);
}
and my code is as follows:
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);
});
my console output from this:
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.
What have I done incorrectly? The blockchain API documentation is here: https://blockchain.info/api/api_websocket and I've tried both URLs they specify. Omitting the port number in the URL generates a different error. Instead of "error performing WebClient request", it appears to hunt for a local path to the socket server, which clearly is incorrect.
Any help from a more experienced programmer would be much appreciated