Tom
Tom

Reputation: 1052

SignalR - Unhandled Rejection (Error): WebSocket closed with status code: 1000 ()

An asp.net core application with react+redux on the client side, using signalR. Getting the following error on the client side:

Unhandled Rejection (Error): WebSocket closed with status code: 1000 ().

Seems like this is a "normal closure", but there's no code to close the connection.

The application sends small images at 60 FPS per viewport, in several viewports. This utilizes the JS thread almost completely, to the extent that I'd assume that it may prevent signalR from maintaining keep-alive.

Tried setting the timeouts in the server for signalR to their max value, that did not prevent the issue from recurring.

What is it that could cause the signalR socket to close without invoking the close and without an error message?

Error screenshot

Upvotes: 1

Views: 6471

Answers (2)

Tom
Tom

Reputation: 1052

To solve the issue, I turned on the logs as Jesper suggested. The issue was that I was cancelling a CancellationToken passed to the SendAsync method. For some odd reason cancelling the send closes the socket (I'd expect it to only cancel the specific message, not close the connection).

Upvotes: 1

Jesper
Jesper

Reputation: 7615

I'm guessing the browser or the server could close out of self-preservation or reaching set limits.

As for why the error message is vague: The browser literally can't give you too much feedback about this - see the warning text before 9.3.4. Edit: this is wrong and only applies to close code 1006.

Upvotes: 1

Related Questions