Bug 59710 - java.io.IOException: Connection timed out
Summary: java.io.IOException: Connection timed out
Status: RESOLVED WORKSFORME
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: WebSocket (show other bugs)
Version: 7.0.69
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-15 15:54 UTC by hugo.larson
Modified: 2016-10-05 14:02 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hugo.larson 2016-06-15 15:54:15 UTC
Hello, 

We are using Tomcat 7.0.69 and suspect a bug with session.close() when "Connection timed out" happens sporadically. When the exception is thrown @onError correctly is called and I call session.close but the connection is still open in limbo which cause memory leak. 

On the client we use Tyrus with reconnectHandler and set HeartBeatIntervall to 1 minute. When the timeout exception is thrown in Tomcat, Tyrus is still happy with the connection even though its closed in Tomcat. 

My theory is that there is a problem with session.close() when a timeout occurs. It never really gets closed. 
I have set the connectionTimeout=-1 connectionUploadTimeout=-1 in server.xml. 

Anyone has a clue? 

BR, 
Hugo 

java.io.IOException: Connection timed out 
        at sun.nio.ch.FileDispatcherImpl.read0(Native Method) 
        at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) 
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) 
        at sun.nio.ch.IOUtil.read(IOUtil.java:192) 
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:384) 
        at org.apache.tomcat.util.net.SecureNioChannel.read(SecureNioChannel.java:442) 
        at org.apache.coyote.http11.upgrade.NioServletInputStream.fillReadBuffer(NioServletInputStream.java:136) 
        at org.apache.coyote.http11.upgrade.NioServletInputStream.doRead(NioServletInputStream.java:80) 
        at org.apache.coyote.http11.upgrade.AbstractServletInputStream.read(AbstractServletInputStream.java:129) 
        at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:56) 
        at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHa 
ndler.java:205) 
        at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream 
.java:203) 
        at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:93) 
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623) 
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1749) 
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1708) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
        at java.lang.Thread.run(Thread.java:745)
Comment 1 Mark Thomas 2016-06-15 19:30:32 UTC
This should be fixed in trunk and will be included in the 7.0.70 release currently in progress. If you still see this issue with 7.0.70 please provide the simplest possible test case that demonstrates the issue and we'll take another look.
Comment 2 hugo.larson 2016-06-15 20:36:23 UTC
Will do!

BR,
Hugo
Comment 3 hugo.larson 2016-06-23 10:46:56 UTC
I'm afraid that the problem is not fixed with 7.0.70.
I have no clue to emulate a timeout Exception.

BR,
Hugo
Comment 4 Mark Thomas 2016-06-29 17:24:10 UTC
Stacktrace from 7.0.70 please.
Comment 5 hugo.larson 2016-06-30 21:30:18 UTC
java.io.IOException: Connection timed out
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
	at sun.nio.ch.IOUtil.read(IOUtil.java:192)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:384)
	at org.apache.tomcat.util.net.SecureNioChannel.read(SecureNioChannel.java:442)
	at org.apache.coyote.http11.upgrade.NioServletInputStream.fillReadBuffer(NioServletInputStream.java:136)
	at org.apache.coyote.http11.upgrade.NioServletInputStream.doRead(NioServletInputStream.java:80)
	at org.apache.coyote.http11.upgrade.AbstractServletInputStream.read(AbstractServletInputStream.java:129)
	at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:56)
	at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:204)
	at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:203)
	at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:93)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:621)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1756)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1715)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Comment 6 Mark Thomas 2016-07-01 11:23:25 UTC
I've tried manually triggering an exeception in the relevant code but I still see the server and client session being correctly closed and cleaned up.

To investigate this further we need more information. Ideally, we need a simple web application that demonstrates the problem. We also need details of the memory leak. What references are held by which object to which objects?
Comment 7 Mark Thomas 2016-10-05 14:02:06 UTC
No further response for 3+ months. Resolving as WORKSFORME.