Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR what happens if user is inactive?

Tags:

signalr

I would like to know what will happen if the user is inactive.

Imagine user connected to the hub, the connection is established, but user doesn't refresh the page or doesn't do anything for an hour ... will the connection be maintained anyway?

And after that time can the message be pushed to him?

like image 309
Alnedru Avatar asked Feb 07 '14 10:02

Alnedru


People also ask

How long do SignalR connections stay open?

The default keepalive timeout period is currently 20 seconds. If your client code tries to call a Hub method while SignalR is in reconnecting mode, SignalR will try to send the command. Most of the time, such attempts will fail, but in some circumstances they might succeed.

How do I stop SignalR connection?

hub. stop(). done(function() { alert('stopped'); });

How do I check if my SignalR is reconnecting?

To test reconnect after the server goes down use iisreset. To simulate client connection dropping (good luck) pull the network cable :) Pulling the network cable won't accurately simulate a client connection dropping when you're using Azure SignalR Service.

How do I set SignalR connection timeout?

Timeout configuration for SignalR can be set in Application_Start method of Global class in Global. asax. cs file. // Wait a maximum of 30 minutes after a transport connection is lost // before raising the Disconnected event to terminate the SignalR connection.


1 Answers

SignalR sends keep-alive messages which will keep the connection open even if there is no other activity (except for long-polling connections; in that case, the client will make its regular ajax requests which has the same effect of keeping the connection alive). So you'll be able to send a message after an hour of inactivity, for example.

If the client device goes into sleep mode or can't send those keep-alive messages for any other reason, then the connection will eventually be removed (you can determine the timeout via GlobalHost.Configuration.DisconnectTimeout). Take a look at the documentation for a more detailed explanation.

like image 57
Lars Höppner Avatar answered Nov 08 '22 18:11

Lars Höppner