{"action":"closed","issue":{"url":"https://api.github.com/repos/NanoHttpd/nanohttpd/issues/147","labels_url":"https://api.github.com/repos/NanoHttpd/nanohttpd/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/NanoHttpd/nanohttpd/issues/147/comments","events_url":"https://api.github.com/repos/NanoHttpd/nanohttpd/issues/147/events","html_url":"https://github.com/NanoHttpd/nanohttpd/issues/147","id":48374486,"number":147,"title":"SocketException on client closing the websocket session","user":{"login":"dzlab","id":1645304,"avatar_url":"https://avatars.githubusercontent.com/u/1645304?v=3","gravatar_id":"","url":"https://api.github.com/users/dzlab","html_url":"https://github.com/dzlab","followers_url":"https://api.github.com/users/dzlab/followers","following_url":"https://api.github.com/users/dzlab/following{/other_user}","gists_url":"https://api.github.com/users/dzlab/gists{/gist_id}","starred_url":"https://api.github.com/users/dzlab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzlab/subscriptions","organizations_url":"https://api.github.com/users/dzlab/orgs","repos_url":"https://api.github.com/users/dzlab/repos","events_url":"https://api.github.com/users/dzlab/events{/privacy}","received_events_url":"https://api.github.com/users/dzlab/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-11-11T11:27:04Z","updated_at":"2015-05-14T07:12:07Z","closed_at":"2015-05-14T07:12:07Z","body":"I'm running the `EchoSocketSample` web socket server, with a client using `javax.websocket-api` and [tyrus](https://tyrus.java.net/) as the implementation. Here is how the client is establishing a connection to the server:\r\n```java\r\npublic static void main(String[] args)\r\n  {\r\n    WebSocketContainer container = null;\r\n    Session session = null;\r\n    try\r\n    {\r\n      container = ContainerProvider.getWebSocketContainer();\r\n      session = container.connectToServer(WSClient.class, URI.create(\"ws://localhost:8081/\"));\r\n      session.getBasicRemote().sendText(\"hello web socket server\");\r\n      Thread.sleep(1000);\r\n      LOG.info(\"Done.\");\r\n    }\r\n    catch (Exception e)\r\n    {\r\n      e.printStackTrace();\r\n    }\r\n    {\r\n      if (session != null)\r\n      {\r\n        try\r\n        {\r\n          session.close();\r\n        }\r\n        catch (Exception e)\r\n        {\r\n          e.printStackTrace();\r\n        }\r\n      }\r\n    }\r\n  }\r\n```\r\nWhen the client close the session, then a SocketException is raised on the server as it attempts to write to the closed socket (It should not). Here is the full stack trace:\r\n```java\r\njava.net.SocketException: Connection reset by peer: socket write error\r\n\tat java.net.SocketOutputStream.socketWrite0(Native Method)\r\n\tat java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)\r\n\tat java.net.SocketOutputStream.write(SocketOutputStream.java:138)\r\n\tat fi.iki.elonen.WebSocketFrame.write(WebSocketFrame.java:246)\r\n\tat fi.iki.elonen.WebSocket.sendFrame(WebSocket.java:147)\r\n\tat fi.iki.elonen.samples.echo.DebugWebSocket.sendFrame(DebugWebSocket.java:65)\r\n\tat fi.iki.elonen.WebSocket.handleCloseFrame(WebSocket.java:114)\r\n\tat fi.iki.elonen.WebSocket.handleWebsocketFrame(WebSocket.java:83)\r\n\tat fi.iki.elonen.samples.echo.DebugWebSocket.handleWebsocketFrame(DebugWebSocket.java:57)\r\n\tat fi.iki.elonen.WebSocket.readWebsocket(WebSocket.java:66)\r\n\tat fi.iki.elonen.WebSocket$1.send(WebSocket.java:39)\r\n\tat fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:926)\r\n\tat fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:175)\r\n\tat java.lang.Thread.run(Thread.java:744)\r\n```"}}