react-native-xmpp icon indicating copy to clipboard operation
react-native-xmpp copied to clipboard

How do I know when a message has failed to reach the server?

Open dreson4 opened this issue 7 years ago • 3 comments

Is there anyway to have a callback when I send a message? Because I need to know whether the message reached the server or failed, otherwise I have to assume every message was delivered to the server even when there was an error. A good situation is clients with bad connections.

The current onError(message) function is never called if the user goes offline all of a sudden. And when it gets called sometimes, it just shows that "Server is not connected, please reconnect". It doesn't show which message failed. So if I sent many messages at once, and this function get called then I don't know from which message the fail started.

onDisconnect(message) as well doesn't get called right away when the user goes offline, at least if this was getting called I would have tried to monitor if the user is online before sending the message.

What can I do to know which messages failed and which ones reached the server successfully?

dreson4 avatar Sep 28 '17 07:09 dreson4

Ok I got it. I'll edit the RNXMPPService.m file and return the real message as another argument like this onError(message, realMessage) rather than just returning the string "Server is not connected, please reconnect" that way if realMessage is not null I can figure out each message that failed.

The android part I couldn't figure out though how you return errors on XmppServiceSmackImpl.java

try { chat.sendMessage(text); } catch (SmackException e) { logger.log(Level.WARNING, "Could not send message", e); }

I'll make a PR Request when I get this done in case anyone else needs this feature.

dreson4 avatar Sep 28 '17 07:09 dreson4

hey @dreson4! I'm looking for the similar thing! Please share if you figured out anything yet!

vigasdeep avatar Jan 02 '18 18:01 vigasdeep

Hi @dreson4! I'm looking for a similar thing! Please share if you figured out anything yet!

kamleshsindhal08 avatar Mar 25 '19 07:03 kamleshsindhal08