-
Notifications
You must be signed in to change notification settings - Fork 139
Description
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?