Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Cannot keep alive #57

Open
xavieryao opened this issue Feb 14, 2015 · 3 comments
Open

Cannot keep alive #57

xavieryao opened this issue Feb 14, 2015 · 3 comments

Comments

@xavieryao
Copy link

After connected, it will automatically exit with code 0 after a little while (like 3 minutes)

@Mo33n
Copy link

Mo33n commented Feb 26, 2015

Can you tell which XMPP server you are using ?

@pavankumar9
Copy link

Any update on this issue. Even for me after some time chat messages are not sent.

@cyberwolf
Copy link
Contributor

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);
  }
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants