xmppjs / xmpp.js

XMPP for JavaScript
ISC License
2.19k stars 375 forks source link

Understand reconnect mechanism when disconnect the network and connect again #863

Closed Jade-Jade-Jade closed 3 years ago

Jade-Jade-Jade commented 3 years ago

Hello,

I am trying to understand the mechanism when disconnect the network and connect again.

Say I disconnect with the network, and then I send a message packet, I can see a packet is sent from web socket. But from my understanding, as the network is not connected, the packet is not sent to the server. When I connect with the network again, I can see the response from the server in the same websocket.

I also did not see any reconnecting events happened with xmpp.reconnect.on('reconnecting', () => {});

and no error in xmpp.on('error', (error) => {});

Is there any special reconnect mechanism in this case? Could you help me understand what will happen when disconnect and reconnect the network.

And is it possible to abort the message sent when no network?

Thank you so much!

sonnyp commented 3 years ago

Most likely stream management was enabled.

See https://github.com/xmppjs/xmpp.js/tree/master/packages/stream-management and https://xmpp.org/extensions/xep-0198.html