The default connectTimeout value is set to 20000 and cause issue with WebSocket connection java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at org.apache.coyote.http11.upgrade.UpgradeBioProcessor.read(UpgradeBioProcessor.java:75) at org.apache.catalina.websocket.WsFrame.nextFrame(WsFrame.java:213) at org.apache.catalina.websocket.WsInputStream.nextFrame(WsInputStream.java:68) at org.apache.catalina.websocket.StreamInbound.onData(StreamInbound.java:143) at org.apache.coyote.http11.upgrade.UpgradeProcessor.upgradeDispatch(UpgradeProcessor.java:83) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:563) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) Increasing the value delay the issue (but the timeout should not occurs)
Must we set the timeout to unlimited, or you thing it is better that client can overwrite it?
Salut, I think it should be unlimited, but an idle timeout setting would be useful (I do support idle timeout with Atmosphere, but I think Tomcat could support the same as well). If you want to test using Atmosphere, download atmosphere-spring-websocket.war from search.maven.org (remove the -0.9 in the name) and deploy. After 20 seconds the app will stop working and Chrome will display a protocol exception. Ping me directly if that can help. Thanks! -- Jeanfrancois
I've been thinking about this and I think the following is the way to go. 1. Make the connection timeout infinite. 2. Add an idle timeout to the WebSocket implementation (defaults to infinite) that times out if there is no input or output after a predefined amount of time. This should be configurable per connection. 3. Add a "ping every n milliseconds" feature (disabled by default) to save applications re-inventing the wheel. Thoughts? As an aside, 1) will be tricky with the APR/native connector. That needs some separate work. I'll start a thread on that on the dev list.
Hi Mark, +1 for making the connection timeout infinite. +1 also to add support for websocket timeout property/attribute (will be really useful). Not sure for the ping ... some applications don't need ping or that extra traffic on the wire. At least this should be configurable. Thanks for the work. -- Jeanfrancois
Hi, +1 here for the option of configuring the timeout. My application requires an infinite connection which will be closed when required. I was negatively suprised to see tomcat has such a short timeout option. please add an option to configure this at the very least. meanwhile is there a workaround other than constant client reconnection? thanks
Just a short progress update. I have committed a set of changes to the APR/native connector to permit per socket timeouts. It works with my simple tests but needs more testing and review by some proper C coders (which I am not). I also have a first draft of the changes to trunk to enable infinite timeouts for WebSocket connections. That also needs some testing. I should have something to commit in the next couple of days.
Fixed in trunk. Will be back-ported to 7.0.x once there has been a new release of the APR/native connector.
Ok thanks! I will go ahead and test using trunk. Will report if I see any issues.
Fixed in trunk and 7.0.x and will be included in 7.0.28 onwards.