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

Cannot auth with v0.6.0 #9

Closed lboynton closed 12 years ago

lboynton commented 12 years ago

Hi, it seems with v0.6.0 I can no longer authenticate with the XMPP server (I'm using ejabberd). Here is the log:

+----------------------------------------------------------------------------------------------------------------+
| Starting WEBSOCKET DRAFT 10 server 'v0.6.0' on ws://0.0.0.0:5280' at 'Fri Feb 17 2012 10:35:42 GMT+0000 (GMT)' |
+----------------------------------------------------------------------------------------------------------------+
[2012-02-17 10:35:50.702] [INFO] [http-server.js] - RECD: <body xmlns="http://jabber.org/protocol/httpbind" content="text/xml charset=utf-8" rid="9487908443" xml:lang="en" hold="1" to="abc.com" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0" wait="60" route="xmpp:my.jabber.server:5222"/>
[2012-02-17 10:35:50.710] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a Sent: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="abc.com" version="1.0">
[2012-02-17 10:35:50.713] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a _on_data RECD: <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='3344545251' from='abc.com' version='1.0' xml:lang='en'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>SCRAM-SHA-1</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>
[2012-02-17 10:35:50.714] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a _on_stanza parsed: <stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>SCRAM-SHA-1</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>
[2012-02-17 10:35:50.715] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a Sent: <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
[2012-02-17 10:35:50.715] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a _on_data RECD: <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
[2012-02-17 10:35:50.717] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a _on_stanza parsed: <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
[2012-02-17 10:35:50.749] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a Sent: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="abc.com" version="1.0">
[2012-02-17 10:35:50.750] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a _on_data RECD: <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='2692183849' from='abc.com' version='1.0' xml:lang='en'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>SCRAM-SHA-1</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>
[2012-02-17 10:35:50.751] [ERROR] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a _on_stream_error - will terminate: undefined
[2012-02-17 10:35:50.751] [INFO] [xmpp-proxy.js] - fef2a90b-72bd-4754-8be7-ddd32ad9b0a3 9adb3ccc-9adb-4b1b-8033-6c5ac76a5c9a Sent: </stream:stream>
[2012-02-17 10:35:50.753] [INFO] [response.js] - SENT: <body xmlns="http://jabber.org/protocol/httpbind" type="terminate"/>

It works with v0.5.6, so I assume this is a new bug. For some reason it thinks there is a stream error, but it looks fine to me?

lboynton commented 12 years ago

OK, I now know the actual error is "will terminate: XML or text declaration not at start of entity". I had this issue before because I was sending stanzas with the XML declaration: <?xml version='1.0'?>. When I took that out it worked. My question is should stanzas include the XML declaration? In this case it is ejabberd which is sending it so I'm thinking this is normal behaviour?

dhruvbird commented 12 years ago

We've switched to a new SAX based XML parser for better speed. This might be due to the switch to a SAX based parser. The XML generated by ejabbed looks fine. Will fix.

satyamshekhar commented 12 years ago

Can you please check if commit 0caf940a1b267acb3315d786af5a36c60f3e64de(or current master) fixes the issue.

lboynton commented 12 years ago

I've tested with current master and can confirm that it now works for me. Thanks!