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

Gracefully handle disconnections from the server #11

Closed
biemedia opened this issue Dec 30, 2011 · 5 comments
Closed

Gracefully handle disconnections from the server #11

biemedia opened this issue Dec 30, 2011 · 5 comments

Comments

@biemedia
Copy link

I can get hubot to connect to hipchat and everything works perfectly except it will randomly disconnect and return this error.

Received error from HipChat: Unknown error

/Users/admin/Desktop/hubot/node_modules/hubot-hipchat/node_modules/wobot/node_modules/node-xmpp/lib/xmpp/connection.js:274
this.socket.end();
^
TypeError: Cannot call method 'end' of undefined
at Client.onEnd (/Users/admin/Desktop/hubot/node_modules/hubot-hipchat/node_modules/wobot/node_modules/node-xmpp/lib/xmpp/connection.js:274:17)
at Socket. (/Users/admin/Desktop/hubot/node_modules/hubot-hipchat/node_modules/wobot/node_modules/node-xmpp/lib/xmpp/connection.js:56:14)
at Socket.emit (events.js:81:20)
at Socket._onReadable (net.js:656:51)
at IOWatcher.onReadable as callback

I'm using
"hubot-hipchat": "1.0.1",
"hubot": "2.0.5"

@powdahound
Copy link
Contributor

We always return a reason when disconnecting someone so it sounds like this might just be caused by a network failure somewhere. Also looks like something that node-xmpp is handling incorrectly. I'll try to repro.

@powdahound
Copy link
Contributor

Related: cjoudrey/wobot#6

@rbergman
Copy link
Contributor

This appears to be an issue in node-xmpp, as @powdahound stated above.

I've reproduced this (or something very similar) by sending invalid XML to the HipChat XMPP server, which appears to cause a disconnect. The issue appears to arise from a bug in node-xmpp. Browsing node-xmpp issue list, there's quite a bit of discussion about issues related to this and similar issues (including xmppjs/xmpp.js#111), usually suggesting that the next major version of node-xmpp would solve them through a major refactor. Unfortunately, node-xmpp appears to have since fallen out of maintenance...

The stack traces I've seen for the issue don't make it look like we can install an exception trap to handle it gracefully, since the troubled stacks don't pass through our code. The best we could do (short of getting node-xmpp fixed) is to install a global exception trap, but doing so is an established node-antipattern. Node prefers to have troubled processes be restarted (e.g. with the likes of Forever.js, upstart/monit, etc) when critical errors like these occur.

@bjeanes
Copy link

bjeanes commented Aug 6, 2013

@rbergman This is apparently fixed by xmppjs/xmpp.js#122 ... have you tried bumping the dependency version, yet?

@bjeanes
Copy link

bjeanes commented Aug 6, 2013

It should also be noted that I was experiencing this and tracked it down to problems compiling lib-expat. I followed the directions on xmppo/node-expat#52 (specifically rm -rf ./node_modules ~/.npm ~/.node-gym; npm install and I stopped experiencing the problem.

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

No branches or pull requests

3 participants