Could Not Connect strophe js connection after DISCONNECTED status

420 views Asked by At

Currently I have integrating strophe in my chat application.Its working fine until user is online But, when i try to switch the another wifi connection in my system, strophe sends the DISCONNECTED I don't have any idea to make it to reconnect automatically in such situation. Please help me to fix this issue.

1

There are 1 answers

0
Praveen Kumar On

If you are using BOSH to connect to your server then you can add keepalive to your connection string

new Strophe.Connection(this._xmppConnectionsString, { 'keepalive': true })

If you are using Web Sockets to connect then you need to write a setInterval after the initial connection success.

    setInterval(function(){ 
                    this._xmppConnection.send($pres().tree()); 
                }, 12000);

This should solve your problem.