You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am facing issue to connect SocketIO to c# based server.
if I am using pure WebSocket it connects to the server but from socketio it not connecting.
I have attached my client side code as well as server side alongwith the errror trace anybdoy can please help me on the same
SERVER CODE :
var szData = new ASCIIEncoding().GetString(e.Buffer, 0, count).Replace("\0", "");
if (Regex.IsMatch(szData, "^GET", RegexOptions.IgnoreCase))
{
string swk = Regex.Match(szData, "Sec-WebSocket-Key: (.)").Groups[1].Value.Trim();
string path = Regex.Match(szData, "GET (.)").Groups[1].Value.Trim();
string host = Regex.Match(szData, "Host: (.)").Groups[1].Value.Trim();
string origin = Regex.Match(szData, "Origin: (.)").Groups[1].Value.Trim();
string swka = swk + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
byte[] swkaSha1 = System.Security.Cryptography.SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(swka));
string swkaSha1Base64 = Convert.ToBase64String(swkaSha1);
string request = "GET " + path + " \r\n" +
"Upgrade: WebSocket\r\n" +
"Connection: Upgrade\r\n" +
"Host: " + host + "\r\n" +
"Origin: " + origin + "\r\n" +
"Sec-WebSocket-Accept: " + swkaSha1Base64 + "\r\n\r\n";
CLIENT CODE:
var sioclient = io.connect('ws://192.168.0.2:9250/', {upgrade: false, transports: ['websocket'],reconnectionDelay:5000});
this._sioClient = sioclient;
//if you need to track multiple sockets it is best to store them with tags in your own array for now
this.tag = sioclient.tag = "Test Client";
//register event callbacks
//this is an example of a handler declared inline
sioclient.on("connect", function () {
console.log("Connected");
// Send message after connection
self._sioClient.send("Hello Socket.IO!");
});
sioclient.on("error", function (event) {
console.log("onerror");
console.log(event.code);
// Send message after connection
//self._sioClient.send("Hello Socket.IO!");
});
ws://192.168.0.2:9250/
socket-io.js:1068 parse ws://192.168.0.2:9250/
socket-io.js:63 new io instance for ws://192.168.0.2:9250/
socket-io.js:299 readyState closed
socket-io.js:302 opening ws://192.168.0.2:9250/
socket-io.js:1667 creating transport "websocket"
socket-io.js:1758 setting transport websocket
socket-io.js:334 connect attempt will timeout after 20000
socket-io.js:299 readyState opening
socket-io.js:338 connect attempt timed out after 20000
socket-io.js:2183 socket close with reason: "forced close"
socket-io.js:2128 socket closing - telling transport to close
socket-io.js:317 connect_error
assets\Utility\AsyncSocket.ts:53 timeout
socket-io.js:555 will wait 3847ms before reconnect attempt
socket-io.js:561 attempting reconnect
assets\Utility\AsyncSocket.ts:70 reconnecting
socket-io.js:299 readyState closed
socket-io.js:302 opening ws://192.168.0.2:9250/
socket-io.js:1667 creating transport "websocket"
socket-io.js:1758 setting transport websocket
socket-io.js:334 connect attempt will timeout after 20000
The text was updated successfully, but these errors were encountered:
Hi, I am facing issue to connect SocketIO to c# based server.
if I am using pure WebSocket it connects to the server but from socketio it not connecting.
I have attached my client side code as well as server side alongwith the errror trace anybdoy can please help me on the same
SERVER CODE :
var szData = new ASCIIEncoding().GetString(e.Buffer, 0, count).Replace("\0", "");
if (Regex.IsMatch(szData, "^GET", RegexOptions.IgnoreCase))
{
string swk = Regex.Match(szData, "Sec-WebSocket-Key: (.)").Groups[1].Value.Trim();
string path = Regex.Match(szData, "GET (.)").Groups[1].Value.Trim();
string host = Regex.Match(szData, "Host: (.)").Groups[1].Value.Trim();
string origin = Regex.Match(szData, "Origin: (.)").Groups[1].Value.Trim();
string swka = swk + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
byte[] swkaSha1 = System.Security.Cryptography.SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(swka));
string swkaSha1Base64 = Convert.ToBase64String(swkaSha1);
string request = "GET " + path + " \r\n" +
"Upgrade: WebSocket\r\n" +
"Connection: Upgrade\r\n" +
"Host: " + host + "\r\n" +
"Origin: " + origin + "\r\n" +
"Sec-WebSocket-Accept: " + swkaSha1Base64 + "\r\n\r\n";
CLIENT CODE:
var sioclient = io.connect('ws://192.168.0.2:9250/', {upgrade: false, transports: ['websocket'],reconnectionDelay:5000});
this._sioClient = sioclient;
//if you need to track multiple sockets it is best to store them with tags in your own array for now
this.tag = sioclient.tag = "Test Client";
ws://192.168.0.2:9250/
socket-io.js:1068 parse ws://192.168.0.2:9250/
socket-io.js:63 new io instance for ws://192.168.0.2:9250/
socket-io.js:299 readyState closed
socket-io.js:302 opening ws://192.168.0.2:9250/
socket-io.js:1667 creating transport "websocket"
socket-io.js:1758 setting transport websocket
socket-io.js:334 connect attempt will timeout after 20000
socket-io.js:299 readyState opening
socket-io.js:338 connect attempt timed out after 20000
socket-io.js:2183 socket close with reason: "forced close"
socket-io.js:2128 socket closing - telling transport to close
socket-io.js:317 connect_error
assets\Utility\AsyncSocket.ts:53 timeout
socket-io.js:555 will wait 3847ms before reconnect attempt
socket-io.js:561 attempting reconnect
assets\Utility\AsyncSocket.ts:70 reconnecting
socket-io.js:299 readyState closed
socket-io.js:302 opening ws://192.168.0.2:9250/
socket-io.js:1667 creating transport "websocket"
socket-io.js:1758 setting transport websocket
socket-io.js:334 connect attempt will timeout after 20000
The text was updated successfully, but these errors were encountered: