Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322578

Summary: wrong representation of length in WebSocket binary data frame
Product: [RT] Jetty Reporter: nloe_dev <support.nloe>
Component: serverAssignee: Greg Wilkins <gregw>
Status: CLOSED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3 CC: jetty-inbox, mgorovoy
Version: unspecified   
Target Milestone: 7.1.x   
Hardware: PC   
OS: Linux   
Whiteboard:

Description nloe_dev CLA 2010-08-12 15:33:53 EDT
Build Identifier: M20100211-1343

Current way of processing length of binary data in WebSocket frame is somehow doesn't match the WebSocket specification at http://www.whatwg.org/specs/web-socket-protocol/, which, I believe, is the latest version of this specification.
In the section of Data framing (for server and for client) it states, that length of the binary data in the frame should be represented as 64-bit unsigned integer, meaning that after frame byte(0xFF) and the data itself should be 8-bytes, representing length of the sending data.

In current WebSocket implementation methods WebSocketConnection.sendMessage(frame, data[]) or  WebSocketConnection.sendMessage(frame, data[], offset, length) and underlying methods in sending frame is not represented by 8 bytes, but represented only by amount of bytes required for holding the length value.

Eg:
sending message 5 bytes of data 45 46 47 48 49
should send:
   ff 00 00 00 00 00 00 00 05 45 46 47 48 49
will send:
   ff 05 45 46 47 48 49

I just made my own implementation of WebSocket client based on the latest specification of the protocol at http://www.whatwg.org/specs/web-socket-protocol/ and just found this inconsistency issue. 
I believe this issue with handling length as 8 byte value also present in the receiving methods.

Please, fix this issue in sake of faster development of this great and very promising web protocol.
Many thanks. 

Reproducible: Always

Steps to Reproduce:
1.Connect any WebSocket client to the WebSocket servlet
2.Use any packet sniffer while sending some data using functions  WebSocketConnection.sendMessage(frame, data[]) or  WebSocketConnection.sendMessage(frame, data[], offset, length) 
  to see sending data frame.
Comment 1 Greg Wilkins CLA 2010-08-16 09:25:27 EDT
Ah politics!

That version is not the IETF draft and there is no consensus around the changes made in that version (nor any rigour about when they are made).

For a view into the politics see:
  http://www.ietf.org/mail-archive/web/hybi/current/threads.html#03136

That discussion and similar issues has ultimately resulted in a change of editor for the IETF draft:
  http://www.ietf.org/mail-archive/web/hybi/current/threads.html#03198

Jetty will be following the IETF drafts as they are correctly submitted and will be viewable at 
https://datatracker.ietf.org/doc/draft-ietf-hybi-thewebsocketprotocol/
Comment 2 Jesse McConnell CLA 2011-09-20 15:52:06 EDT
Resolved -> Closed