Closed AUrban closed 2 years ago
Maybe the message you received is a special case, I received this:
{"sid":"BpXgajlbwVH1qR4QBvKz","upgrades":[],"pingInterval":10000,"pingTimeout":5000}
Which version of socket.io server do you use?
Hello! The service is compatible with the following librariy for Socket.IO: 2.3.0
Hi!
Do you have any idea about what might be wrong?
Hi! Looks good. When are going to release that?
The thing is I'm using this library via NuGet
has been released
Hi @doghappy!
I've got this exception when trying to connect to socket.io server:
** Exception Text ** 12:57:26 [FTL] : System.InvalidOperationException: The requested operation requires an element of type 'Number', but the target element has type 'String'. at System.Text.Json.JsonDocument.TryGetValue(Int32 index, Int32& value) at System.Text.Json.JsonElement.GetInt32() at SocketIOClient.Messages.OpenedMessage.Read(String msg) at SocketIOClient.Messages.MessageFactory.CreateMessage(Int32 eio, String msg) at SocketIOClient.Transport.TransportRouter.OnTextReceived(String text) at System.Threading.Tasks.Task.<>c.b__140_1(Object state)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
I'v reseached the problem and found that the cause is in these rows (in the Read method of the OpenedMessage class):
PingInterval = root.GetProperty("pingInterval").GetInt32(); PingTimeout = root.GetProperty("pingTimeout").GetInt32();
With this, the message looks like this: {"sid":"zW8GQnX9N0bPS1tUAARQ","upgrades":[],"pingInterval":"15000","pingTimeout":"10000"}
if corrected as follows, the problem disappears:
PingInterval = Int32.Parse(root.GetProperty("pingInterval").GetString()); PingTimeout = Int32.Parse(root.GetProperty("pingTimeout").GetString());
What could be wrong? Could you please give me a recommendation how to avoid such problems?