xmppjs / xmpp.js

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

manually reconnect when receive error packet #848

Closed Jade-Jade-Jade closed 3 years ago

Jade-Jade-Jade commented 3 years ago

From https://github.com/xmppjs/xmpp.js/tree/master/packages/client, the reconnect is automatically. But I would like to have some control for deciding when to reconnect and how long should I wait for next reconnect according to error packet type. Is it possible?

Thank you!

sonnyp commented 3 years ago

@Jade-Jade-Jade did you have a look at https://github.com/xmppjs/xmpp.js/tree/master/packages/reconnect ?

You can access the reconnect object via client.reconnect. Beside reconnect.delay, you can use reconnect.stop() and reconnect.start.

If you need more control I would suggest disabling the plugin with reconnect.stop and implementing the logic yourself.

Jade-Jade-Jade commented 3 years ago

@sonnyp Thank you for the response, I am able to access the reconnect object!