tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Piatek1 <anton.pia...@uk.ibm.com>
Subject websockets holding on to threads.
Date Fri, 05 Apr 2013 13:07:02 GMT
I am seeing what at first appears to be a bug, but given the lack of other 
reports I can't believe I am the only person seeing this, so maybe it is 
user-error.

I have tomcat (was 7.0.30, but I just tried with 7.0.39) running a website 
which uses websockets. The websockets code in tomcat isn't that 
complicated - My servlet returns a new subclass of StreamInbound which has 
overridden the onTextData() and onBinaryData() methods. This seems to 
generally work fine, and I can send and receive data happily.

However when I load up several browser windows I find that tomcat hangs. I 
used jconsole to check the tomcat threads and found that as I open each 
new websocket, the tomcat worker threads go from idle threads waiting for 
work to the following busy, blocking threads waiting for websocket data.

Name: http-bio-4415-exec-5
State: RUNNABLE
Total blocked: 50  Total waited: 112

Stack trace: 
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:161)
java.net.SocketInputStream.read(SocketInputStream.java:132)
org.apache.coyote.http11.upgrade.UpgradeBioProcessor.read(UpgradeBioProcessor.java:81)
org.apache.catalina.websocket.WsFrame.nextFrame(WsFrame.java:214)
org.apache.catalina.websocket.WsInputStream.nextFrame(WsInputStream.java:68)
org.apache.catalina.websocket.StreamInbound.onData(StreamInbound.java:149)
org.apache.coyote.http11.upgrade.UpgradeProcessor.upgradeDispatch(UpgradeProcessor.java:83)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:587)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
   - locked org.apache.tomcat.util.net.SocketWrapper@ddb0d168
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:626)
java.lang.Thread.run(Thread.java:780)

I am trying to figure out what I am missing. I didn't think I needed to 
override StreamInbound.onData() in my class, but as that seems to be what 
is keeping the thread busy, presumably waiting for data looking at that 
stack. 

Am I misunderstanding something, or is this possibly a tomcat bug?
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message