JsonHubProtocol is trying to parse my returned Json string
Clash Royale CLAN TAG#URR8PPP
JsonHubProtocol is trying to parse my returned Json string
I’m using Asp.Net Core and Angular 5 and SignalR
I am invoking a hub request from my client that goes to the hub and then to my server which returns a json string back to my hub and then back to the client. For some reason when the JSON string is returned from the hub back to the client (I confirmed that the json string is valid at this point), JsonHubProtocol decides it wants to parse the json string for reasons I can’t even begin to understand and then it throws this error:
vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:12769 ERROR
SyntaxError: Unexpected token t in JSON at position 101966
at JSON.parse (<anonymous>)
at JsonHubProtocol.parseMessages (JsonHubProtocol.js:26)
at HubConnection.processIncomingData (HubConnection.js:233)
at WebSocketTransport.HubConnection.connection.onreceive (HubConnection.js:53)
at WebSocket.webSocket.onmessage (WebSocketTransport.js:84)
at WebSocket.wrapFn [as __zone_symbol___onmessage] (vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:108115)
at ZoneDelegate.invokeTask (vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:107483)
at Object.onInvokeTask (vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:16071)
at ZoneDelegate.invokeTask (vendor.js?v=qKeAFyUtI3So5rvopMsnQH_TWvFGR_LotO0ksrPFlXc:107482)
at Zone.runTask
I can not for the life of me figure out what is wrong as the json I am returning is valid and being rejected from a SignalR Hub Script that decides it wants to inspect my returned string and when it discovers the string is json it throws an error. It only seems to happen 10% of the time when my server receives a new piece of data and has to re-serialize the Json data and send it to the client side.
@davidfowl I'll try that. A part of me feels like the client connection to the hub is ending before the data can be returned back to the client but I feel like I would receive a different error if that were the case.
– Alex Wenger
Aug 8 at 13:15
See if it repros without the "zone" APIs. I've seen it cause other problems
– davidfowl
Aug 9 at 6:12
@davidfowl I think the issue was that the data being returned was being truncated as the data was larger than signalr transport is suppose to handle. But I can't figure out why JsonHubProtocol would be parsing the string when it detects its json. It should be none of JsonHubProtocol's business whether or not the string I return is json....
– Alex Wenger
Aug 22 at 14:13
> I think the issue was that the data being returned was being truncated as the data was larger than signalr transport is suppose to handle That should never happen. If you can reproduce it file an issue on github. > It should be none of JsonHubProtocol's business whether or not the string I return is json. It doesn't care. It'll see it as a string. But you need to file an issue with more details so that we can try to reproduce the issue.
– davidfowl
Aug 24 at 16:09
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
If you can capture a network trace it'd be very helpful
– davidfowl
Aug 8 at 7:42