Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reconnection issues #66

Merged
merged 5 commits into from
Mar 27, 2014
Merged

Fix reconnection issues #66

merged 5 commits into from
Mar 27, 2014

Conversation

markstory
Copy link
Contributor

I think this resolves #58 and #63. When ejabberd - and I assume other xmpp servers - are hard reset node-xmpp gets a ECONNREFUSED error which prevents the reconnect option from working. In these situations, the end event is emitted. The adapter now handles this event and attempts to reconnect.

If this reconnection process fails the bot process will be terminated. This will allow process managers like supervisord to restart the bot.

When ejabberd is restarted with `ejabberdctl restart` the node-xmpp
client does not enter a reconnect state. Instead the connection is
ended. This code attempts to handle reconnection in a somewhat janky
way.

A more intelligent backoff is probably required.
Testing timers is much easier with sinon.
@Soulfire86
Copy link

Does anyone have confirmation that this fixes #58?

@markstory
Copy link
Contributor Author

From my limited local testing with ejabberd it solved problems where hubot would not come online after ejabberd restart.

Remove any listeners from the previous connection as they can cause
issues with messages being logged more than once.
markstory added a commit that referenced this pull request Mar 27, 2014
@markstory markstory merged commit 92f11cc into master Mar 27, 2014
@markstory markstory deleted the fix-reconnect branch March 27, 2014 02:26
@bnied
Copy link

bnied commented Apr 1, 2014

I'm still seeing duplicated responses and log entries, even with the new changes:

hubot-dev [9:05 AM]
PONG

bnied [9:05 AM] [this command causes a reset with Slack]
hubot-dev show storage

bnied [9:07 AM]
hubot-dev ping

hubot-dev [9:07 AM]
PONG

hubot-dev [9:07 AM]
PONG

hubot-dev [9:07 AM]
PONG

hubot-dev [9:07 AM]
PONG

hubot-dev [9:07 AM]
PONG

hubot-dev [9:07 AM]
PONG

@markstory
Copy link
Contributor Author

I'm not sure of what the problem is then. How is the connection being reset?

@bnied
Copy link

bnied commented Apr 5, 2014

I'm running a command which is causing Slack to send an offline event.

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

Successfully merging this pull request may close these issues.

Hubot does not reconnect on disconnect
3 participants