Reputation: 4054
I need to connect Node.js based WebSocket from a C# windows form code
Node module used https://github.com/Automattic/socket.io
I am using superwebsocket and WebSocket4Net
using SuperSocket.Common;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Config;
using SuperSocket.SocketBase.Logging;
using SuperWebSocket;
using SuperWebSocket.SubProtocol;
using WebSocket4Net;
......
......
WebSocket webSocketClient = new WebSocket("ws://localhost:8080/");
webSocketClient.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(webSocketClient_Error);
webSocketClient.AllowUnstrustedCertificate = true;
webSocketClient.Opened += new EventHandler(webSocketClient_Opened);
webSocketClient.Closed += new EventHandler(webSocketClient_Closed);
webSocketClient.MessageReceived += new EventHandler<MessageReceivedEventArgs>(webSocketClient_MessageReceived);
webSocketClient.Open();
But only webSocketClient_Error callback triggers always, can anyone help?
Upvotes: 3
Views: 4732
Reputation: 4054
Node.JS socket.io library uses a different URL pattern but you have given root URL, Please change your URL as follows then it should work
WebSocket webSocketClient = new WebSocket("ws://localhost:8080/socket.io/?EIO=3&transport=websocket");
Upvotes: 10