Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR with unreliable or paused & reconnected connections?

Tags:

signalr

I'm considering updating an existing site to use SignalR. My site polls a third party service for data changes, does some magic on it, and clients poll it once every few minutes to refresh their view with any updates.

SignalR seems like a great way to eliminate the polling from the client, but I want to know how SignalR handles dropped & reconnected connections, especially with regards to mobile web apps which may have been suspended for some time. Will it automatically negotiate and queue up any updates that were missed in the meantime, or does the client need to resynch from scratch in these cases? I looked but couldn't find any docs on this so guidance would be appreciated.

like image 578
Joel P. Avatar asked Oct 12 '11 14:10

Joel P.


1 Answers

All this is definitely possible since the client keeps track of the last message id it saw. If it happened to miss messages, it'll get those the next time it goes back to the server (asking for all messages since the last one it saw).

By default the server side of SignalR stores messages in memory (and it purges those every few seconds), but you can change it to persist to some persistent store (see IMessageStore) if you're thinking about clients going offline and catching up.

You could even persist messages yourself in your own app logic while SignalR stores stuff in memory. It really depends on the application.

We haven't added any special support for mobile clients, but you can persist the message id in whatever local storage you need to for your mobile client.

Those details aren't very specific but what you want to do is all possible with SignalR.

like image 51
davidfowl Avatar answered Nov 16 '22 00:11

davidfowl