xmppo / node-xmpp-bosh

An XMPP BOSH & WebSocket server (connection manager) written on node.js using Javascript
https://github.com/xmppo/node-xmpp-bosh
263 stars 85 forks source link

where is type="terminate" in <body><stream:error><conflict... ? #21

Closed vinnitu closed 12 years ago

vinnitu commented 12 years ago

I received such body if user open chat with same resource

<body xmlns="http://jabber.org/protocol/httpbind" stream="3a59e76d-8e39-40f8-aa7d-f5ea22cefed0"><stream:error xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams"/><text xml:lang="" xmlns="urn:ietf:params:xml:ns:xmpp-streams">Replaced by new connection</text></stream:error></body>

But I waiting for terminate in type attribute of body tag...

When I am wrong? And how to detect such situation?

Thx

dhruvbird commented 12 years ago

Yes, according to the spec (XEP-0206 & XEP-0124), the tag MUST have a tag terminate, but node-xmpp-bosh does not add that tag and instead relies on the client (or server) to close the connection (or terminate the stream). This is a bug, but not a very serious one.

To detect such a situation, just bail out when you see a terminate attribute on a body tag OR a stream:error tag.

vinnitu commented 12 years ago

it seems we need to modify 3d-party library (jsjac) to detect situation and prevent auto reconnect for this case (((

dhruvbird commented 12 years ago

True, will fix in future version.

vinnitu commented 12 years ago

Ok, Thanks.

dhruvbird commented 12 years ago

This should be fixed on current master - let me know if it works for you.

vinnitu commented 12 years ago

node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ TypeError: Cannot call method 'push' of undefined at Object.enqueue_bosh_response (/var/www/home/user/node_modules/node-xmpp-bosh/src/session.js:838:50) at Object.send_stream_terminate_response (/var/www/home/user/node_modules/node-xmpp-bosh/src/stream.js:82:17) at _on_terminate (/var/www/home/user/node_modules/node-xmpp-bosh/src/bosh.js:260:16) at BoshEventPipe.emit (/var/www/home/user/node_modules/node-xmpp-bosh/node_modules/eventpipe/eventpipe.js:63:25) at Object. (/var/www/home/user/node_modules/node-xmpp-bosh/src/xmpp-proxy-connector.js:71:20) at XMPPProxy. (native) at XMPPProxy.emit (events.js:70:17) at XMPPProxy._close_connection (/var/www/home/user/node_modules/node-xmpp-bosh/src/xmpp-proxy.js:300:14) at XMPPProxy._on_close (/var/www/home/user/node_modules/node-xmpp-bosh/src/xmpp-proxy.js:306:14) at Socket. (native)

PS: I am not sure I have right depends PSS: yesterday npm give me 0.5.6 version, but today 0.6.0 PSSS: i have 0.6.14 nodejs

dhruvbird commented 12 years ago

Should be fixed now. Let me know if it still crashes.

vinnitu commented 12 years ago

It's OK.