Search code examples
asp.net-coresignalr.net-4.8asp.net-core-signalr

Why is SignalR throwing an error that doesn't provide any information?


Getting below errors in SignalR.

It should not throw any errors. We are not getting any Error messages. It only says Error. But what not about what error occurred?

enter image description here

Error: Failed to start the transport 'WebSockets': Error: There was an error with the transport. Error: Failed to start the transport 'ServerSentEvents': Error: Error occurred Error: Connection disconnected with error 'Error'. Error: Failed to start the transport 'LongPolling': Error signalr.js:4741 WebSocket connection to 'wss://tst.com/SignalRHub?id=ujZbbgfwN2nbPvjGTIpGBw' failed: [2023-05-22T12:36:24.679Z] Error: Failed to start the connection: Error: Unable to connect to the server with any of the available transports. WebSockets failed: Error: There was an error with the transport. ServerSentEvents failed: Error: Error occurred LongPolling failed: Error

new signalR.HubConnectionBuilder()
  .withUrl(window.location.origin+\"/SignalRHub\", { skipNegotiations: true})
  .withAutomaticReconnect([0, 0, 10000])
  .configureLogging(signalR.LogLevel.Information)
  .build()

All errors are coming at the same time.

It should not throw any errors.


Solution

  • According your description and comment, it sometime works, so I believe there is no code issue in this case.

    You can follow the official doc to check the 404 error first.

    Troubleshoot connection errors - Response code 404

    We can enable sticky sessions correctly to fix the issue.