1

I'm working on a real-time chat. I need to change statuses of the room owner and connected users, together with the UI. Since NodeJS/SocketJS/etc don't guarantee message delivery, I switched to pure Ajax for that.

The system works like that: - User presses a button to change his status - An Ajax request is being sent to the server, and a status change request is being saved in the queue in DB - Users send Ajax heartbeats every second. On the server this heartbeat function also processes the queue (when sent by the room owner). Besides it sends the current statuses of users in the room in response every time.

The issue is: there might be temporary internet problems on both sides, which causes all kinds of problems. This happens due to the fact, that the heartbeat Ajax requests are being processed in an arbitrary order on the server, or the responses are being received in a wrong order on the client side. As a result users have wrong data about current statuses and the UI changes are also wrong.

What is the best approach when making a system like that? What am I doing wrong or how can I fix the issues above?

Thank you!

Alexander
  • 631
  • 1
  • 8
  • 19
  • Waitaminute are you saying django with socketio `don't guarantee message delivery,` ? – Raja Simon Nov 23 '15 at 05:51
  • SocketJS* Well, a message is being sent once - whoever was able to catch it - caught it. https://groups.google.com/forum/#!topic/sockjs/drG5B4PhmeE http://stackoverflow.com/questions/20685208/websocket-transport-reliability-socket-io-data-loss-during-reconnection – Alexander Nov 23 '15 at 05:56
  • The whole stack is (or should I say used to be) is Django + Redis + SockJS + NodeJS. But that's not even the problem I'm trying to solve anymore. – Alexander Nov 23 '15 at 05:58

1 Answers1

0

Have a look at Max's blog a Django-Realtime-Chat and how he does it.

Peter Rosemann
  • 505
  • 8
  • 20
  • Thanks, but I've seen this article a long time ago and this is not the problem I'm trying to solve here. I've already switched to pure Ajax for user status updates, but the thing is if there is a delay due to bad internet connection etc, the Ajax responses come back in a wrong order. Or sometimes just one request gets stuck and return way later - with an old status in it, and then all kinds of mix-ups happen. – Alexander Nov 24 '15 at 11:33
  • With the system from the article, a temporary connection lost will cause a user to miss all the messages, that has been sent during the disconnected time. And I can't afford that, especially when it comes to service messages like status updates. – Alexander Nov 24 '15 at 11:35