I am currently supporting an older application which has a node.js (v0.12.13) server with a socket.io (v1.3.7) connection. This server supports a browser clients very well.
socket.attach(http, { 'transports': ['polling','websocket'], 'allowUpgrades': true });
socket.attach(https, { 'transports': ['polling','websocket'], 'allowUpgrades': true });
socket.sockets.on('connection', function (socket) {
// Process stuff here
});
Our requirements also required that we allow our legacy Windows app to connect to the node server and I had used SocketIoClientDotNet/EngineIoClientDotNet, and this more or less works OK (with some exceptions that I need to handle).
So I thought I would try to use a .NET ClientWebSocket approach, where uri="ws://10.10.5.112", based on this article:
static async Task Connect(string uri)
{
ClientWebSocket sock = new ClientWebSocket();
await sock.ConnectAsync(new Uri(uri), CancellationToken.None);
}
But I get the following exceptions:
System.AggregateException
HResult=0x80131500
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at WebsocketClientTest.Program.Main(String[] args) in C:\Source\test\WebsocketClientTest\Program.cs:line 16
Inner Exception 1:
WebSocketException: Unable to connect to the remote server
Inner Exception 2:
WebException: The underlying connection was closed: The connection was closed unexpectedly.
Sure enough, I don't see any connection attempt at the server, but Wireshark is telling me that the .Net app is trying to initiate the connection, but gets no response from the node.js server. Looks like this a failure at the socket.io side, but any ideas to help me along are appreciated.
User contributions licensed under CC BY-SA 3.0