The io socket emits a failed callback

Is there a way to find out that the io emit socket failed and success, something like ajax: onSuccess, onError callback methods? For the io emit socket, I only find:

socket.emit ('publish', {message: 'test message'}, function (data) {warning ("")})

This callback is only called when the server sends an ack response. But it cannot be used for this situation:

When a message is sent to the server, a bad network or lost connection occurs, which means that the server does not receive this message, therefore, the client callback function is not called.

I want:

When I call the io emit socket, if it fails, I want to retry 3 times.

+8
callback
source share

No one has answered this question yet.

See related questions:

1204
How to access the correct `this` inside a callback?
746
How to pass parameter to callbackTimeout ()?
613
What is a callback function?
29th
jQuery: feedback rollback for failed AJAX request
28
Is socket.io emit callback appropriate?
4
Socket.io raw data will disconnect the client
one
Socket IO does not receive emitted data after reconnecting
0
Socket io emitting several times for the same client
0
How to disable socket after socket.emit shutdown
0
Emit or Ack timeout on Android socket.IO?

All Articles