Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Sending data over the server end of a WebSocket

Hi,

I am trying to get communications between two Java programs using a
Websocket. One has an embedded Jetty server running a WebSocketServlet
instance, and the other has a java implementation of a WebSocket
client.

The client can connect to the server and send data, and the server can
send data back to the client through the Outbound object. This works
fine for messages smaller than 3 kilobytes.

However, I would like to send messages much larger than that (they
contain base64-encoded binary data). If I try and send a message
larger than 3 kilobytes, I get:
java.lang.IllegalArgumentException: frame too large
        at org.eclipse.jetty.websocket.WebSocketGenerator.addFrame(WebSocketGenerator.java:91)

Since the limit of a WebSocket frame seems to be 3kb, how can I break
up a message and send it in multiple frames? Actually I dont really
understand the frame thing very well, as you can specify any number
for the frame (and the same number multiple times) and the message
still reaches the other end in exactly the same way. In my
understanding, a frame should be a "chunk" of data, but then why can
the user specify a number for it? You'd think that the underlying
network would take care of chunking up the data as it does for a
standard TCP socket.

Can somebody please help me?

Cheers,
Erin


Back to the top