https://bz.apache.org/bugzilla/show_bug.cgi?id=64644
Bug ID: 64644 Summary: wrong state of WsSession on network outage Product: Tomcat 9 Version: 9.0.31 Hardware: PC OS: Linux Status: NEW Severity: major Priority: P2 Component: WebSocket Assignee: dev@tomcat.apache.org Reporter: saksham.ve...@gmail.com Target Milestone: ----- Created attachment 37382 --> https://bz.apache.org/bugzilla/attachment.cgi?id=37382&action=edit a web project to start a ws server and index.html showing value of active websocket connections This issue happens on any Linux OS, when we have a remote websocket connection stable and then, network drops. If the application is writing on that websocket channel, then the lastActiveTime keeps on getting updated even if there is no network. The writes are successful for next ~15 minutes because the keep-alive interval for tcp is 15 minutes. Thus, from the time network was dropped to next 15 minutes the WsSession is shown as active. And if the application is not writing anything on that channel, then after the maxIdleTimeout the WsSession.checkExpiration closes the connection. But when application is writing it shows wrong state of websocket session. Steps to reproduce: 1. Start the attached web project on a linux OS. It sets the maxIdleTimeout to 10 seconds and if any websocket session is created it sends a message every 2 seconds. 2. On any remote system connect a websocket session. I used the "smart websocket client" extension in chrome. 3. Check that the /WebsocketActiveTimeIssue/index.html shows 1. 4. Drop the network connection between the client and server. I was using a VM so, I disconnected the network from Oracle virtual box. 5. For next 15 minutes that webpage will keep showing 1. Root cause: Tomcat updates the lastActiveTime anytime application writes anything on that channel. Thus, WsSession.checkExpiration() method never expires it unless the transport layer throws an error which happens only after 15 minutes. Effect: In my product, I need to show the devices which are connected to my IoT platform. The devices send the ping every T seconds (T is much less than maxIdleTimeout), thus, if there were any Idle Read events, then I could use that to close the connection and show the device as disconnected. Suggestion: Have two types of active times. viz. One for read and one for write: Throw an IdleRead or IdleWrite event when any of the active times are passed the maxIdle timeout. I have tried a fix on my system. But I don't know how to raise a PR with that. Though I am on the dev mailing list but got recently added. -- 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