socket.io-client-csharp icon indicating copy to clipboard operation
socket.io-client-csharp copied to clipboard

Not able to build connection in .Net C# using SocketIOClient.SocketIO class

Open NandishNR opened this issue 1 year ago • 4 comments

@doghappy,

  1. Server package version: "https://www.npmjs.com/package/socket.io/v/2.5.0"
  2. Client package version: Latest version, 2.0.0, 2.3.0,3.0.0, etc..
  3. Client built using .Net 6.0
  4. Able to build connection using postman
  5. Checked Wireshark logs as well - nothing blocked on laptop like antivirus or proxy

Below is the code, where not able to build connection and execution will not comeout from "await _socketIO.ConnectAsync();". Connected flag is false and not able emit the message.

SocketIOOptions options = new SocketIOOptions(); options.Path = SocketPath; options.Query = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("token", Accesstoken), new KeyValuePair<string, string>("deviceId", DeviceId) }; options.Transport = SocketIOClient.Transport.TransportProtocol.WebSocket; options.Reconnection = true; options.ReconnectionDelayMax = 10; options.ReconnectionDelay = 1000; options.ConnectionTimeout = TimeSpan.FromMilliseconds(10000);

Uri uri = new Uri(SocketUri); SocketIOClient.SocketIO _socketIO = new SocketIOClient.SocketIO(uri, options); _socketIO.OnConnected += OnSocketIOConnected; _socketIO.OnReconnected += OnSocketIOReconnected; _socketIO.OnError += OnSocketIOError; await _socketIO.ConnectAsync();

NandishNR avatar May 09 '24 12:05 NandishNR

Hi @doghappy,

Upgraded sever to latest package and able to connect .net client. However, what ever sever emit the events .net client is not received but received in react client.

Any inputs on this?

NandishNR avatar May 13 '24 13:05 NandishNR

Hi @NandishNR sorry for the slow response. Are you tried to set the options.EIO = EngineIO.V3

doghappy avatar May 13 '24 14:05 doghappy

Hi @doghappy, I have the same problem. I have set the parameters, EIO = EngineIO.V3,

var client = new SocketIOClient.SocketIO(URL, new SocketIOOptions
{
    Path = "/myPath",
    EIO = SocketIO.Core.EngineIO.V3
}); 

But still can not connect. I use Nodejs connection, add a parameter, rejectUnauthorized: false,

const socket = io(URL, { path: "/myPath", rejectUnauthorized: false});
socket.on("connect", () => 
  Log("Socket connected");
});

can be connected. I want to know how to add this parameter?

navyxhj avatar Aug 17 '24 23:08 navyxhj