{"action":"created","issue":{"url":"https://api.github.com/repos/playframework/playframework/issues/1388","repository_url":"https://api.github.com/repos/playframework/playframework","labels_url":"https://api.github.com/repos/playframework/playframework/issues/1388/labels{/name}","comments_url":"https://api.github.com/repos/playframework/playframework/issues/1388/comments","events_url":"https://api.github.com/repos/playframework/playframework/issues/1388/events","html_url":"https://github.com/playframework/playframework/issues/1388","id":17288598,"number":1388,"title":"Websocket clients can disconnect ungracefully, don't notify application","user":{"login":"andrewconner","id":1394531,"avatar_url":"https://avatars.githubusercontent.com/u/1394531?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewconner","html_url":"https://github.com/andrewconner","followers_url":"https://api.github.com/users/andrewconner/followers","following_url":"https://api.github.com/users/andrewconner/following{/other_user}","gists_url":"https://api.github.com/users/andrewconner/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewconner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewconner/subscriptions","organizations_url":"https://api.github.com/users/andrewconner/orgs","repos_url":"https://api.github.com/users/andrewconner/repos","events_url":"https://api.github.com/users/andrewconner/events{/privacy}","received_events_url":"https://api.github.com/users/andrewconner/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2013-07-26T22:50:33Z","updated_at":"2016-05-01T01:31:29Z","closed_at":"2013-10-16T06:31:25Z","body":"When using a long-lived websocket connection, clients frequently are able to disconnect uncleanly. Typically this happens (on desktop and mobile) when they lose wifi signal, close their laptop lid, power off abruptly, etc.\r\n\r\nPlay doesn't seem to get any notification this has happened, so the server believes the client is still connected. Taken from the Play examples:\r\n\r\n```scala\r\n    def index = WebSocket.using[String] { request => \r\n      val in = Iteratee.foreach[String](println).mapDone { _ =>\r\n        println(\"Disconnected\")\r\n      }\r\n      val out = Enumerator(\"Hello!\")\r\n      (in, out)\r\n    }\r\n```\r\n\r\nYou'd expect that the mapDone would be called in all cases. However, in unclean disconnect cases, it's not called.\r\n\r\nTo reproduce, you'll likely need two computers (or virtual machines). Run Play! on one, and connect with the other. If you disconnect by closing the browser, leaving the page, etc, everything works as expected. Reconnect, then cause the client to abruptly disconnect (`kill -9` does not work here) — my favorite is using a virtual machine and simulating pulling the power.\r\n\r\n\"Disconnected\" *never* hits the console. This is more than a bookkeeping issue, because it can cause resources to be left open, and for the server to try to push things down the socket.\r\n\r\nI realize that much of this may be hitting limits of netty. However, what are our options here? Our current solution is an application-level ping, with a cleanup actor. Works alright for websockets, but not so well for something like a chunked response."},"comment":{"url":"https://api.github.com/repos/playframework/playframework/issues/comments/216007012","html_url":"https://github.com/playframework/playframework/issues/1388#issuecomment-216007012","issue_url":"https://api.github.com/repos/playframework/playframework/issues/1388","id":216007012,"user":{"login":"pauldraper","id":1403271,"avatar_url":"https://avatars.githubusercontent.com/u/1403271?v=3","gravatar_id":"","url":"https://api.github.com/users/pauldraper","html_url":"https://github.com/pauldraper","followers_url":"https://api.github.com/users/pauldraper/followers","following_url":"https://api.github.com/users/pauldraper/following{/other_user}","gists_url":"https://api.github.com/users/pauldraper/gists{/gist_id}","starred_url":"https://api.github.com/users/pauldraper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pauldraper/subscriptions","organizations_url":"https://api.github.com/users/pauldraper/orgs","repos_url":"https://api.github.com/users/pauldraper/repos","events_url":"https://api.github.com/users/pauldraper/events{/privacy}","received_events_url":"https://api.github.com/users/pauldraper/received_events","type":"User","site_admin":false},"created_at":"2016-05-01T01:31:29Z","updated_at":"2016-05-01T01:31:29Z","body":"> There are open tickets for read/idle timeouts, these would apply to both WebSockets and ordinary requests.\r\n\r\n@jroper, I cannot find these issues https://github.com/playframework/playframework/issues?utf8=%E2%9C%93&q=is%3Aissue+idle"}}