'Asp Net Core SignalR Exception thrown: 'System.IO.InvalidDataException' in Microsoft.AspNetCore.SignalR.Protocols.Json.dll

I get an exception from the SignalR client application(Exception thrown: 'System.IO.InvalidDataException' in Microsoft.AspNetCore.SignalR.Protocols.Json.dll). This is happening when the signalR Hub send messages to a channel that the client is not configured to listening on. The functionality that i want is described below: The Signalr server Hub sends messages into channels like "Test1","Test2","Test3". The SingalR client want to receive messages only for the Test1 channel because the particular user screen/page is associated only with the Test1 channel's messages. Then, the other two unhandled channels throws exceptions. So, the client needs to listening to all channels that the server sends to? I thought the On<>() method is meant for the client in order to subscribe to the channels where he is interested.

What am i missing? Thanks in andvance!



Solution 1:[1]

Ran into this issue for a SignalR hub connection with angular client and .net 5.0 server. Below is the screen shot of the error details on the server side. In this instance I was sending a decimal as part of the json payload like "value": 8.3. The issue went away once I converted the decimal to a string like this "value": "8.3"

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sarvpk