ASP.NET Core 3.1 SignalR connections reconnect after 2 minutes for some clients

Viewed 1016

I have an asp.net core 3.1 project with signalr. Some of my users seem to disconnect/reconnect their websockets signalr connection every 2 minutes: logs of 2 minute reconnections

This is ever better visualized by this chart:

2 minute reconnections chart

I'm aware that by default there's a 2 minute keepalive timeout on websockets controlled by asp.net - but as far as I know signalr also has it's own ping/keepalive messages specifically to avoid the websocket timeout - if I open mine I can see those clearly:

websockets keepalive messages

So the question is: why do some people's connections get broken off at 2 minutes?

Edit 1: removed my mac/linux theory as I've found some windows clients in the logs

Edit 2: I managed to score a console log from one of the affected clients:

console log from client

1 Answers

This is due to the KeepAlive settings which default to 2 min in your ASP.NET core server.

Documentation here !

Either add a ping-pong mechanism to keep the websocket connection open or raise this settings.

Related