{"action":"created","issue":{"url":"https://api.github.com/repos/socketio/socket.io/issues/3259","repository_url":"https://api.github.com/repos/socketio/socket.io","labels_url":"https://api.github.com/repos/socketio/socket.io/issues/3259/labels{/name}","comments_url":"https://api.github.com/repos/socketio/socket.io/issues/3259/comments","events_url":"https://api.github.com/repos/socketio/socket.io/issues/3259/events","html_url":"https://github.com/socketio/socket.io/issues/3259","id":326749221,"node_id":"MDU6SXNzdWUzMjY3NDkyMjE=","number":3259,"title":"JS exceptions thrown while just idling (WebSocket is already in CLOSING or CLOSED state.)","user":{"login":"getify","id":150330,"node_id":"MDQ6VXNlcjE1MDMzMA==","avatar_url":"https://avatars1.githubusercontent.com/u/150330?v=4","gravatar_id":"","url":"https://api.github.com/users/getify","html_url":"https://github.com/getify","followers_url":"https://api.github.com/users/getify/followers","following_url":"https://api.github.com/users/getify/following{/other_user}","gists_url":"https://api.github.com/users/getify/gists{/gist_id}","starred_url":"https://api.github.com/users/getify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getify/subscriptions","organizations_url":"https://api.github.com/users/getify/orgs","repos_url":"https://api.github.com/users/getify/repos","events_url":"https://api.github.com/users/getify/events{/privacy}","received_events_url":"https://api.github.com/users/getify/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-05-26T16:12:17Z","updated_at":"2018-07-18T08:48:16Z","closed_at":null,"author_association":"NONE","body":"### You want to:\r\n\r\n* [x] report a *bug*\r\n* [ ] request a *feature*\r\n\r\n### Current behaviour\r\n\r\nWhile leaving a socket connected, but doing no other activity in my program, I see intermittently (but fairly consistently) an exception thrown in browser console, from inside of the socket.io machinery (specifically in `backo2/index.js` line 83. That error is:\r\n\r\n```\r\nWebSocket is already in CLOSING or CLOSED state.\r\n```\r\n\r\n![socket-io-errors](https://user-images.githubusercontent.com/150330/40578108-ece715fc-60d3-11e8-876c-3f759fdbca4c.png)\r\n\r\n### Steps to reproduce (if the current behaviour is a bug)\r\n\r\nI have two tabs open with client sockets connected to the same server (localhost) via https. Both clients are sitting idle with nothing else happening in browser or server (except for whatever keep-alive pings socket.io is doing). Both of them are joined to a single channel (via `join(..)` on the server). Otherwise, nothing else special.\r\n\r\nHere's how I create the server socket instance:\r\n\r\n```js\r\nvar httpsServer = https.createServer(..);\r\nvar io = require(\"socket.io\")(httpsServer);\r\nio.on(\"connection\",onSocketConnection);\r\n```\r\n\r\nAnd in the client:\r\n\r\n```js\r\nsocket = io();\r\nsocket.on(\"connect\",function(){\r\n   console.log(\"socket connected\");\r\n});\r\nsocket.on(\"disconnect\",function(){\r\n   console.log(\"socket disconnected\");\r\n});\r\n```\r\n\r\n### Expected behaviour\r\n\r\nI expect disconnections and reconnections from time to time, but I don't expect spurious JS exceptions thrown by the library when I'm not doing anything else over the connections.\r\n\r\n### Setup\r\n- OS: Mac OSX\r\n- browser: Chrome 66, node 10.2.1\r\n- socket.io version: 2.1.1\r\n\r\n### Other information (e.g. stacktraces, related issues, suggestions how to fix)\r\n\r\nExpanded stack trace:\r\n\r\n```\r\nindex.js:83 WebSocket is already in CLOSING or CLOSED state.\r\n(anonymous) @ index.js:83\r\ne.encodePacket @ index.js:83\r\n(anonymous) @ index.js:83\r\nr.write @ index.js:83\r\nr.send @ index.js:83\r\nr.flush @ index.js:83\r\nr.sendPacket @ index.js:83\r\nr.ping @ index.js:83\r\n(anonymous) @ index.js:83\r\nsetTimeout (async)\r\nr.setPing @ index.js:83\r\nr.onPacket @ index.js:83\r\n(anonymous) @ index.js:83\r\nr.emit @ index.js:83\r\nr.onPacket @ index.js:83\r\nr.onData @ index.js:83\r\nws.onmessage @ index.js:83\r\n```"},"comment":{"url":"https://api.github.com/repos/socketio/socket.io/issues/comments/405858222","html_url":"https://github.com/socketio/socket.io/issues/3259#issuecomment-405858222","issue_url":"https://api.github.com/repos/socketio/socket.io/issues/3259","id":405858222,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTg1ODIyMg==","user":{"login":"amerej","id":19491145,"node_id":"MDQ6VXNlcjE5NDkxMTQ1","avatar_url":"https://avatars3.githubusercontent.com/u/19491145?v=4","gravatar_id":"","url":"https://api.github.com/users/amerej","html_url":"https://github.com/amerej","followers_url":"https://api.github.com/users/amerej/followers","following_url":"https://api.github.com/users/amerej/following{/other_user}","gists_url":"https://api.github.com/users/amerej/gists{/gist_id}","starred_url":"https://api.github.com/users/amerej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amerej/subscriptions","organizations_url":"https://api.github.com/users/amerej/orgs","repos_url":"https://api.github.com/users/amerej/repos","events_url":"https://api.github.com/users/amerej/events{/privacy}","received_events_url":"https://api.github.com/users/amerej/received_events","type":"User","site_admin":false},"created_at":"2018-07-18T08:48:16Z","updated_at":"2018-07-18T08:48:16Z","author_association":"NONE","body":"Same problem. "}}
{"actor":{"display_login":"amerej"}}