Open xavieryao opened 9 years ago
Can you tell which XMPP server you are using ?
Any update on this issue. Even for me after some time chat messages are not sent.
I'm using this library to connect to HipChat and also encountered that the connection gets closed by the server after a while.
I checked how the Hubot hipchat adapter (which also uses xmpp) tackles this, as I knew that one does not suffer from this issue, and that one seems to send a "r" Stanza in regular time intervals (each 30 seconds).
Based on the hubot example, I've implemented this in my own app, which seems to solve the connection drops by the server:
var keepAlive;
var ping = function () {
xmpp.conn.send(new Client.Stanza('r'));
};
xmpp.on('online', function(data) {
keepAlive = setInterval(ping, 30000);
});
xmpp.on('close', function() {
if (keepAlive) {
clearInterval(keepAlive);
}
});
After connected, it will automatically exit with code 0 after a little while (like 3 minutes)