3

Is there a way to ensure a socket.io-client message is received by the socket.io server? I see there a acknowledgement mechanism available in socket.io. Can we retry sending the message again if the acknowledgement is not received (is there any standard pattern around this) or will socket.io-client retry sending the message if the acknowledgement is not received in some stipulated time?

My application is using socket.io-client over a 2g cell network. 98% of the time the message gets to the server without any issues. That other 2% the message is lost due to the issues with the cellular network from what I can tell.

It will claim to have a socket connection and the data will be transmitted but the server side never gets it. I want to know if there is a sure fire way to make sure that the client message has got to the server. Each of my clients already has an ID but cant just assume that the message got there.

Does anyone have an example of how to resend the same message if acknowledgement has not been made in a certain time frame. I don't even care if the same message gets transmitted again, it's undesirable but not that important to me.

r0w
  • 31
  • 4

1 Answers1

0

The most flexible way is to build your own acknowledgement mechanism. If you are using timeout, you may need to guard against duplicate messages, because the supposedly lost message could eventually arrive.

As an alternative, simple AJAX can ensure the message gets delivered, and it's more reliable than websocket as well. But, you may need to rebuild your existing system, judge by yourself if it's worth it.

Maria
  • 3,455
  • 7
  • 34
  • 47
  • I found this: [Websocket transport reliability (Socket.io data loss during reconnection)](https://stackoverflow.com/questions/20685208/websocket-transport-reliability-socket-io-data-loss-during-reconnection) – r0w Aug 11 '17 at 13:37
  • an update: Found a more reliable solution using MQTT – r0w Sep 19 '17 at 19:12