TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.

Home Page:http://tootallnate.github.io/Java-WebSocket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

using fragmentation problem

JanuNoo opened this issue · comments

Hello,

I want to test a websocket server for fragmentation compliance using this library.
As I can read from rfc 6455:

"
A fragmented message consists of a single frame with the FIN bit
clear and an opcode other than 0, followed by zero or more frames
with the FIN bit clear and the opcode set to 0, and terminated by
a single frame with the FIN bit set and an opcode of 0
"
So I tried doing the following:

ws.sendFragmentedFrame(Opcode.BINARY, ByteBuffer.wrap(new byte[]{1,2,3}), false);
ws.sendFragmentedFrame(Opcode.CONTINUOUS, ByteBuffer.wrap(new byte[]{4,5,6}), false);
ws.sendFragmentedFrame(Opcode.CONTINUOUS, ByteBuffer.wrap(new byte[]{7,8,9}), true);

where ws is an instance of a class that extends WebSocketClient.

but got the following error:

"Only Opcode.BINARY or Opcode.TEXT are allowed".

Any ideas what I am doing wrong?
Thanks

Nevermind.
It seems that if you do the following:

ws.sendFragmentedFrame(Opcode.BINARY, ByteBuffer.wrap(new byte[]{1,2,3}), false);
ws.sendFragmentedFrame(Opcode.BINARY, ByteBuffer.wrap(new byte[]{4,5,6}), false);
ws.sendFragmentedFrame(Opcode.BINARY, ByteBuffer.wrap(new byte[]{7,8,9}), true);

internally it sends the frames as rfc 6455 dictates.