https://issues.apache.org/bugzilla/show_bug.cgi?id=55633
Bug ID: 55633 Summary: [websocket] Tomcat can't read data from the client when the client temporarily pauses Product: Tomcat 8 Version: trunk Hardware: PC Status: NEW Severity: normal Priority: P2 Component: WebSocket Assignee: dev@tomcat.apache.org Reporter: kpreis...@apache.org As reported on Re: 8.0.x / 7.0.x progress thread [1]: For NIO and APR connector: It seems that when a client establishes a Websocket connection and then stops to read data from it (but doesn't close the connection, so that at Tomcat's side writing data to the underlying TCP connection will be blocked), and then after some time the client continues to read data from the Websocket connection, then Tomcat seems not to be able to read data from that client any more (and doesn't notice when the connection has been closed), but it can still write data to the client. To reproduce: Update trunk to r1529443. Then apply the following patch locally to make the issue easier to reproduce (by blowing the amount of data that Tomcat sends to the client): Index: webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java =================================================================== --- webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java (revision 1529443) +++ webapps/examples/WEB-INF/classes/websocket/snake/SnakeTimer.java (working copy) @@ -73,8 +73,10 @@ sb.append(','); } } - broadcast(String.format("{\"type\": \"update\", \"data\" : [%s]}", - sb.toString())); + char[] random = new char[8192]; + java.util.Arrays.fill(random, 'x'); + broadcast(String.format("{\"type\": \"update\", \"data\" : [%s], \"randomData\": \"[%s]\"}", + sb.toString(), new String(random))); } protected static void broadcast(String message) { 1) Start Tomcat (current trunk) on Windows 64-bit with Java7 64-bit and either NIO or APR connector. 2) Start IE (10+) and Firefox and with both browsers open the snake example. On both browsers, press up or down key so that both snakes begin moving. 3) Suspend the Firefox processes. This can be done with "Process Explorer" [2] tool by right-clicking on the firefox.exe entry and select "Suspend". You can see that Firefox does not respond any more, but on IE the snakes continue to move. 4) After some seconds, you can see that on IE the snakes suddenly stop moving. This is correct because the current code uses RemoteEndpoint.Basic that may block on write() methods. 5) Now resume Firefox with Process Explorer. You can see that on both browsers the snakes will continue to move. This means that both browsers are able to receive data from the Websocket connection. 6) When you try to change the direction of the snake in IE, everything works. However on Firefox, the snake will not change its direction. This means that while Tomcat continues to send data to this Websocket connection, it cannot receive from it any more. 7) If you close Firefox, then the corresponding snake will not disappear (so it seems Tomcat doesn't notice that the connection closed). Note: This only applies to the NIO and APR connectors - with BIO, the problem doesn't occur. With Wireshark you can see that FF still sends the direction data correctly and Tomcat ACKs the packets, but does not seem to be able to process them. [1] http://markmail.org/message/z6qklqiceyftapfx [2] http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org