Does anyone know the purpose of Sec-WebSocket-Key and the associated Accept? I know the hashing stuff ( https://en.wikipedia.org/wiki/WebSocket ) but I don't understand why it exists.
A WebSocket Primer
21–24 of 24 posts
Re: A WebSocket Primer
#22Is there a commandline http client that can negotiate WebSockets? If so, I might be tempted to experiment.
Re: A WebSocket Primer
#23Earlier quoted context omitted.
Agreed. Both approaches have their place, but I see SSE getting overlooked too often.
I'm not 100% up to speed on SSE but since there is no way to "push" to a client isn't it just some form of polling at the end of the day? It's also not supported by IE yet: http://caniuse.com/eventsource Compare with http://caniuse.com/websockets
Probably long-poll, a single connection from client to server kept alive with the occasional byte sent one way which sends the message and disconnects when there is something to send (the disconnect, requiring a new request from the client is because some clients won't process what has been sent immediately unless the connection is closed).
I once wrote a messaging client that operated this way. It is efficient in terms of bandwidth use and client footprint, though if you are using a process based we server it can be quite inefficient there (an event driven service on few processes/threads is far more efficient for handling many long-lived low-activity connections).
Re: A WebSocket Primer
#24Does anyone know the purpose of Sec-WebSocket-Key and the associated Accept? I know the hashing stuff ( https://en.wikipedia.org/wiki/WebSocket ) but I don't understand why it exists.
It's there to help guarantee that the server the browser is connecting to actually understands websockets and isn't being "tricked" into opening a connection through clever request formulation. With that guarantee in place, browsers can trust servers to properly check for and limit cross-domain requests and the like and not need to use something like CORS to negotiate that stuff.