redsolution / xabber-websocket

Standalone WebSocket connection manager needed to connect Xabber for Web to multiple different XMPP servers
https://www.xabber.com
GNU Affero General Public License v3.0
11 stars 7 forks source link

missing jabber:client namespace on stanzas #5

Closed agnauck closed 5 years ago

agnauck commented 5 years ago

the jabber:client namespace is missing on stanzas. This causes several clients and libraries fail to connect.

See here from a log from stanza.io which hangs on resource binding because its namespace aware and expects the response Iq to be in the jabber:client xml namespace:

Send:
<iq xmlns="jabber:client" type="set" id="578b0ba8-cb98-46a2-a383-3de028c081f9">
   <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
</iq>

Recv:
<iq id='578b0ba8-cb98-46a2-a383-3de028c081f9' type='result'>
   <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
      <jid>alex@server.com/6ec5214c-4afa-46c4-b3da-f6bc42ac345e</jid>
   </bind>
</iq>
oxoWrk commented 5 years ago

WS Server not change stanzas, it only forwards them. Look your XMPP server

agnauck commented 5 years ago

WS Server not change stanzas, it only forwards them

this is exactly the issue when you forward the complete text of a stanza without referencing it to the complete XMPP stream.

Here is a pseudo stream.

<stream:stream
    from='example.com'
    xmlns='jabber:client'
    xmlns:stream='http://etherx.jabber.org/streams'
    version='1.0'>
<iq type="set" id="578b0ba8-cb98-46a2-a383-3de028c081f9">
   <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
</iq>
</stream:stream>

the default namespace is defined on the stream header (jabber:client). It gets inherited by default to all child stanzas, this is why it is omitted on the iq stanza in this sample here.

By just forwarding the text/string of the stanza you are putting it in the default XML namespace, instead of the jabber:client namespace on the websocket connection.

Stanzas in websocket frames must be independently parsable XML documents, and also conform to the namespaces defined in the XMPP core specs. This is why you have to rewrite the stanza and add the namespace back. By not doing this the implementation will not be compatible with fully namespace aware client implementations, while it still may work with implementations which are not that strict.

oxoWrk commented 5 years ago

fixed in version 0.1.2