[jdev] Websockets RFC: stream: prefix required or not?

Lance Stout lancestout at gmail.com
Mon Feb 2 22:17:35 UTC 2015


> What is your opinion on this? Is MongooseIM or Strophe.js’ behaviour correct?


MongooseIM is correct here. I would also check that Strophe is handling stream errors correctly.



Every WebSocket message has to be a well-formed, independently parseable chunk of XML. Which means that all namespaces and prefixes MUST be defined inside that chunk. Everything else follows from that requirement.



You can either use the namespace directly without a prefix:

<features xmlns="http://etherx.jabber.org/streams" />
<error xmlns="http://etherx.jabber.org/streams" />

or if you wish to use the 'stream' prefix (or any prefix) you MUST declare it inside that element:

<stream:features xmlns:stream="http://etherx.jabber.org/streams" />
<stream:error xmlns:stream="http://etherx.jabber.org/streams" />




I called this out in 7395 because both stream features and errors traditionally use the 'stream' prefix while relying on the opening <stream> tag to define to define the prefix. But for WebSocket there is no parent <stream> tag providing those declarations, and it seemed like an easy item for implementors to either miss entirely or do incorrectly like so:

// Not define the namespace or prefix at all
<stream:features />
<stream:error />

// Define the namespace without a prefix, while still using a prefix
<stream:features xmlns="http://etherx.jabber.org/streams" />
<stream:error xmlns="http://etherx.jabber.org/streams" />

// Stamp 'jabber:client' as the namespace because it has no xmlns attribute
<stream:error xmlns="jabber:client" />
<stream:features xmlns="jabber:client" />



— Lance
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4240 bytes
Desc: not available
URL: <https://www.jabber.org/jdev/attachments/20150202/21dfc2f8/attachment.bin>


More information about the JDev mailing list