Detect missed messages/missed actions on messages on reconnect

1k views Asked by At

I am using SignalR in my application to send messages to different users in a group.

We have the capability that messages can be added/edited or deleted and the same action is sent to all the users in that group via SignalR hub.

All that is working fine.

The issues is one could miss other people actions (message add/edit/delete) which happened during the time when his connection was lost/ internet disconnected or his laptop/machine was off.

After getting connection back or opening the laptop again that user must receive all those missed messages, missed actions which occurred during the time he was offline.

We are storing all clients (client id) of all users in database.

Can anyone give the pointers how to do that?

One solution can be to poll last message id (which has come to ui) to server check if any new message is there but that won't serve the purpose because message could have been edited/deleted at server from other user.

I have already gone through following links

Can SignalR handle missed messages?

Can a SignalR message loss be detected server side?

How to do guaranteed message delivery with SignalR?

Signalr client to retrieve missed messages on reconnect

https://github.com/JabbR/JabbR/issues/699

but none of them is covering the aspect for the entire history which happened during the time user was offline.

For example if you are disconnected in Skype and comes back say after few hrs it pulls all the history of all actions (message added/edited/deleted) that occurred during that time and update it to end user

1

There are 1 answers

0
Alex Shtuk On

Since SignalR doesn't povide any guarantees of message delivery - one should solve this by himself.

There are several approaches:

The first is to use message queues (ex: RabbitMQ). This is the most efficient way to guarantee that message is delivered to client. But in your case you'll need to combine message queueng with pub/sub way of communication. That can be tricky.

The second way is described in the answer to one of SO posts, that you referenced: Can SignalR handle missed messages?. Don't send data over signalr, only notifications; then get the data update from the server. That is my favourite way of client-server notification/update scheme. And I'd choose it in your case.

One solution can be to poll last message id (which has come to ui) to server check if any new message is there but that won't serve the purpose because message could have been edited/deleted at server from other user.

To overcome this you can poll not the last message, but history of actions made in conversation (add/update/delete message actions) since last updated and apply it on the client side.