12

Say my network connection drops for a few seconds and I miss some SignalR server-pushed messages.

When I regain network connectivity are the messages I missed lost? or does signalR handle them and push them out when I reconnect?

If it can't handle missed messages, then what is the recommended approach for ensuring consistency?

  • Periodically (2-3 mins) poll to check server-data?
  • Somehow detect loss of network on the client side and do an ajax call to get the data on network restoration?
  • something else?
reach4thelasers
  • 26,181
  • 22
  • 92
  • 123

1 Answers1

11

Here are a couple of thoughts:

If you aren't sending a lot of messages per second, consider sending no data in the messages themselves. Instead, the message is just a "ping" to the clients telling them to go get the server data when they can. Combine that with a periodic poll, as you said, and you can be assured that you won't miss messages. They just might be delayed.

If you are sending a lot of messages quickly, how about adding a sequential ID to each one? Think of a SQL Identity column. Your clients would need to keep track of the most recent ID received. After a network reconnect, the client could ask for all messages since [Last ID]. If a message is received whose ID is not contiguous with the most recently received, you know that there was a disconnect and can ask the server for the missing information.

MikeC
  • 441
  • 3
  • 8
  • 1
    Interesting Idea, I like the second one, although would be nice if SignalR wrapped up this functionality for us... maybe in a later version I guess! – reach4thelasers Apr 27 '12 at 09:12
  • 1
    I understand what you want, but the idea behind messaging is fire and forget. So I dont see this as a being a core piece of signalR. I agree with the workaround @MikeC suggests as a good option tho. – John Papa Apr 27 '12 at 14:15
  • 1
    Do we have any option or feature to turn on and off like "Drop Messages randomly" in SignalR? – Kurkula May 04 '16 at 07:02