Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] WebSocket message batching in 9.2.3

Hey Simone,

I'm never seeing more than one millisecond delay between sendString() and writeSuccess() and I'm always seeing writeSuccess() called (ie no instances of writeFailed()) so it doesn't sound like the TCP connection is congested.
Besides, the clients aren't generally under much load.

Can you think of anything that might cause the messages to batch?


On Wed, Mar 25, 2015 at 7:34 PM, Simone Bordet <sbordet@xxxxxxxxxxx> wrote:

On Sat, Mar 21, 2015 at 7:58 AM, William Ferguson
<william.ferguson@xxxxxxxxxxxxx> wrote:
> More a query than anything else.
> I am using Jetty-9.2.3 to co-ordinate a bit over a dozen mobile devices on a local wi-fi network using WebSockets.
> I have wrapped the WebSockets in a ReliableSender so that if the client doesn't acknowledge a message within 500ms the server sends it again until it times out after 5 retries.
> Most of the time it works OK, but I am seeing instances where the server sends a message to a client, doesn't get an ACK, so resends, and keeps resending every 500ms (times as recorded by the logging in the code shown below) until it times out after 2.5 seconds. But looking at the client log the client receives the first message more than 2.5 seconds after the server claims to have sent it. And then the client receives all the resends within the next 50ms. So it appears that the messages may have been batched.

Another option is that the client does not read them fast enough so
that the TCP connection is congested.
In that case, the WriteCallback won't be called until the TCP
connection is decongested.

Normal sequence of events:
* sendString()
* writeSuccess()
* start timer task waiting for client ack
* receive client ack
* cancel timer task

You must start the timer task only if writeSuccess() is called.
If it's not called, your TCP connection is congested, and there is no
point in starting the timer task.

Simone Bordet
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top