Read timeout in websocket connection

751 views
Skip to first unread message

pasanbsb

unread,
Aug 15, 2014, 2:25:04 AM8/15/14
to cometd...@googlegroups.com
Hi,

We have a CometD 3.0 server with embedded Jetty 9. CometD client is based on the Java Websocket chat client shipped with CometD 3.0 samples. When client handshake with the server, Websocket connection get closed after some time with java.net.SocketTimeoutException: Timeout on Read.

{"id":"10","failure":{"message":{"id":"10","connectionType":"websocket","channel":"/meta/connect","clientId":"sao1erik5k1bv52lbjytdwk4gv5"},"exception":"java.net.SocketTimeoutException: Timeout on Read","connectionType":"websocket"},"subscription":null,"successful":false,"channel":"/meta/connect"}

 

system: Connection to Server Broken

system: Connection to Server Opened

{"id":"11","successful":true,"channel":"/meta/connect","advice":{"interval":100,"reconnect":"retry","timeout":60000}}

 

{"id":"13","failure":{"message":{"id":"13","connectionType":"websocket","channel":"/meta/connect","clientId":"sao1erik5k1bv52lbjytdwk4gv5"},"exception":"java.net.SocketTimeoutException: Timeout on Read","connectionType":"websocket"},"subscription":null,"successful":false,"channel":"/meta/connect"}

 

system: Connection to Server Broken


This happens only when server is not sending any data. When there server streams data it works fine.

We have done a load test with stre aming data. After about 17000 clients, clients not receiving any data and produce about read timeout error.

Please advice. Please find the server configuration and client code below.

CometD Servelet configuration.
        WebSocketServerContainerInitializer.configureContext(servletContextHandler);


        ServletHolder comet = new ServletHolder(cometdServlet);
        comet.setInitParameter("timeout", "60000");
        comet.setInitParameter("maxIdleTime", "60000");
        comet.setInitParameter("interval", "100");
        comet.setInitParameter("maxInterval", "10000");
        comet.setInitParameter("multiSessionInterval", "5000");
        comet.setInitParameter("services", "CMService");
        comet.setInitParameter("transports", JettyWebSocketTransport.class.getName() + "," + JSONTransport.class.getName());
        comet.setInitParameter("ws.cometdURLMapping", "/cometd/*");
        comet.setInitOrder(0);
        servletContextHandler.addServlet(comet, "/cometd/*");


Client Code : http://pastebin.com/genFV6Tw

Thanks in advanced.


Simone Bordet

unread,
Aug 18, 2014, 4:38:04 PM8/18/14
to cometd-users
Hi,
The configuration parameter is called "ws.idleTimeout", not "maxIdleTime".
Furthermore, it must be greater than the "timeout" parameter,
otherwise you risk that the 2 timeouts have a race, and the
idleTimeout wins.
I normally suggest to have the idleTimeout as twice the timeout.

> comet.setInitParameter("interval", "100");
> comet.setInitParameter("maxInterval", "10000");
> comet.setInitParameter("multiSessionInterval", "5000");
> comet.setInitParameter("services", "CMService");
> comet.setInitParameter("transports",
> JettyWebSocketTransport.class.getName() + "," +
> JSONTransport.class.getName());
> comet.setInitParameter("ws.cometdURLMapping", "/cometd/*");
> comet.setInitOrder(0);
> servletContextHandler.addServlet(comet, "/cometd/*");
>
> Client Code : http://pastebin.com/genFV6Tw

Client code looks good, apart setting the idleTimeout to 15000, which
is less than the 60000 you set as timeout.
Same reasoning as above: the client will break the connection after
15s, but the server is being told to hold /meta/connect for 60s, so
like above, set the idleTimeout to twice the timeout.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
Reply all
Reply to author
Forward
0 new messages