问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/21625879/signalr-what-happens-if-user-is-inactive