Websocket gets an update - the details.
axod.blogspot.com
axod.blogspot.com
It will catch on because it's all we've got, but we're going to shove yet another mediocre protocol onto the stack of protocols servers need to speak in addition to HTTP.
The people working on this have spent time understanding the problem domain better than I have. But I really hope they've thought this protocol through. Because we'll be stuck with it for a long time.
The protocol is a bit more readable here: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-...
The security protocol does seem a little strange: putting numbers into the fields interspersed with random characters and spaces, taking the numbers and dividing them by the number of space characters, and using 2 fields to make harder. There's a lot of dancing here to ensure that the protocol is implemented correctly.
Also, I don't appreciate this mindless bashing on XMPP. All IETF protocols are encouraged (required?) to be fairly secure, which entails things like TLS and SASL. Once you get beyond that, XMPP is not very complex at all. If you have a specific complaint, I'd love to hear it. The XSF is basically as open as the IETF and we're always interested in feedback, but we'd appreciate it if it was constructive.
When the Internet works, it's thanks to Postel's Law, which is the polar opposite of designing a protocol to maximize the likelihood of failure.
This leads us to Ruby's Corollary[1]: Be exact in what you send and liberal in what you accept. Since programmers will neither read the spec nor run the test suite, you should build real implementations that exercise every facet of the spec (e.g. randomize anything that doesn't matter). The only way to interoperate with such implementations is to do things more or less correctly.
[1] After Sam Ruby, who inserts test cases into his blog to encourage browsers and feed readers to work better.
At that point, defining the fact that you are sending a big-endian 64-bit integer It might seem trivial now that we write everything in Java, but endianness caused all kinds of portability problems in the early internet days when we started making different systems talk to each other, and made simple porting jobs difficult. It's how we ended up with network-byte-order instead of just using long ints and stuff like that - it's very easy to overlook.
In short, being specific about data formats matters.
And yeah, it would suck if they over-complicate things - let's not let that happen - we need simple protocols, but not too simple. It's okay if you can slightly abuse them if it means fast adoption (One can coax HTTP servers to sign into IRC and spam channels - but it's not a big enough problem to warrant redesigning the whole thing, right?)
As I say, it's treated, by both sides, as 8 bytes of random data. Never as integers. The endianness here is irrelevant. The spec is going into way more detail than it needs.
If the value is random and you send the low byte first and then treat that as the high byte it would work. I can't imagine that ever being useful, but it works as long as both sides agree that that [FE, ED, FA, CE] is 0xFEEDFACE.
If your RNG gives you 0xFEEDFACE you better not send it out as [CE, FA, ED, FE] or you're going to make a mess of things. Host byte order is completely irrelevant.
My point was, that generating a random 64bit integer and storing it as little endian, would infact work fine. Because the 8 bytes of random data is only used in the context of "8 bytes of random data", and never as "an integer" by both sides.
The spec is just ridiculously overly specific. It's telling us how you can generate 8 bytes of random data. Any programmer implementing it should have a vague idea how to do that.
[ a bit later ... ]
I decided to check the spec and see for myself what's going on. The part you're talking about, key3, is in fact used later. The bytes may be random but both sides need to know which of the 8 bytes comes first and which comes last.
Let /challenge/ be the concatenation of /number_1/, expressed as
a big-endian 32 bit integer, /number_2/, expressed as a big-
endian 32 bit integer, and the eight bytes of /key_3/ in the
order they were sent on the wire.
If the other side doesn't agree on the order of the bytes in key3 then things are not going to work. Your other complaints may be valid but sometimes this sort of over-specification helps implementers.What really matters, is that the protocol is secure, efficient and extensible. If it needs to be more complex in order to meet those criteria, then fine...
I'm not enough of an expert to weigh in, but the spec did make me chuckle. Super verbose with a dash of paranoia.
This is pretty funny (although gregw has written many longer and more detailed essays about websockets as well):
https://bugs.eclipse.org/bugs/show_bug.cgi?id=294563
In the end, we located the bug within our code connecting jetty's websocket support to our message passing system. You can bet that was an adventure to sort out. =)
Be glad you don't study law! It's practically written in a different language to everyday, pragmatic English. Specs and math papers can descend to similar levels of readability, though RFCs, on the whole, tend to (in comparison) be quite readable IMHO.
If you don't understand the point of sending values over the wire in a known order then I'm sorry but I don't trust your ability to properly evaluate the rest of the spec either.
axod: I don't mean this as a personal attack but considering your strong opinions on this I'd expect you to have thought about it more diligently.