Just a follow up on this (would still love some authoritative input).

Setting BatchMode.OFF was not sufficient. Messages still appeared to be
occasionally getting batched.
I am now also calling RemoteEndPoint.flush() after each send and so far I
haven't noticed any batching, nor any performance degrade.

What's the difference between setting BatchMode.OFF and calling flush()
after each send?
Shouldn't they be equivalent?

William

ᐧ

On Sat, Mar 21, 2015 at 4:58 PM, William Ferguson <
[email protected]> 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.
>
> The sends on the server never take more that one milli. This is the code I
> am using.
>
> final long currentTime = 
> System.currentTimeMillis();getRemote().sendString(outboundTextMessage, new 
> WriteCallback() {
>
>     @Override
>     public void writeFailed(Throwable e) {
>         log.debug("#sendMessage could not send remote=" + 
> getRemoteClientDescription() + " message=" + message, e);
>     }
>
>     @Override
>     public void writeSuccess() {
>         final long elapsedTime = System.currentTimeMillis() - currentTime;
>         log.debug((isResend ? "#resendMessage" : "#sendMessage") + " remote=" 
> + getRemoteClientDescription() + " message=" + message + " msToSend=" + 
> elapsedTime);
>     }
> });
>
>
> Could this be because the messages are getting batched by Jetty's
> WebSocket implementation?
> This would mean that the batching is done AFTER writeSuccess(), correct?
>
> How do I ensure that batching doesn't occur? And what would be the cost of
> adopting that approach?
>
> Should I flush after each send?
>
> http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.html#flush()
>
> Or should I configure the RemoteEndPoint#setBatchMode(BatchMode.OFF)?
>
> http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.html#setBatchMode(org.eclipse.jetty.websocket.api.BatchMode)
>
>
> William
>
> ᐧ
>
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to