[Libwebsockets] Q: websockets frame properties

Andy Green andy at warmcat.com
Sat Jul 5 05:13:27 CEST 2014



On 06/23/2014 08:27 PM, Michael Haberler wrote:
> sorry if I ask something obvious, but I'm not deep enough into the ws specs:
>
> 1. assuming binary write: are frame boundaries guaranteed to be preserved ? Can I rely on JS interpreters receiving them as the unit sent ?
> 2. are zero-lenght frames legit and preserved?

The only thing that's guaranteed to go through intermediaries unchanged 
is the "message".

ws framing is like tcp fragmentation you can't make any assumptions that 
what you sent did not get coalesced or refragmented.

> the background of the question -  do I need to explicitly add a frame length field if I do this:
>
> several projects try to bridge zeroMQ sockets to JS via websockets; doing that properly requires retaining the zeromq message structure, which is in a nutshell:
>
> - all frames are size/buffer notation (explicit length field, no interpretation of buffer contents)
> - zero-length frames are legit and have a meaning at the protocol ZMTP [1] level, so must be preserved
> - several frames may be grouped into what is called a multipart message, a sequence of several frames; this is usally done by a flag value tacked onto each frame (ZMQ_MORE !=0 meaning - more frames coming)
>
> to map multipart messages onto ws frames, I guess we need:
>
> - guarantee frame boundaries are retained (if the ws protocol guarantees that - fine, if not, a length field is needed)
> - retain zero length frames (either by that explicit length field, or if the ws protocol guarantees that - fine too)
> - provide the more/final flag - maybe just a bit in the length field
>
> thanks in advance! it's really about blunder prevention, so advice appreciated.

I don't think this is guaranteed to fly.  You can send them but 
intermediaries don't guarantee they'll send it back out the same or even 
bother to send the 0 length frames.

-Andy

> - Michael
>
>
> ZMTP[1]: see section 'Framing' which explains how zeromq frames are assembled: http://rfc.zeromq.org/spec:15
>
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>



More information about the Libwebsockets mailing list