{"action":"created","issue":{"url":"https://api.github.com/repos/Atmosphere/atmosphere-javascript/issues/153","labels_url":"https://api.github.com/repos/Atmosphere/atmosphere-javascript/issues/153/labels{/name}","comments_url":"https://api.github.com/repos/Atmosphere/atmosphere-javascript/issues/153/comments","events_url":"https://api.github.com/repos/Atmosphere/atmosphere-javascript/issues/153/events","html_url":"https://github.com/Atmosphere/atmosphere-javascript/issues/153","id":58348229,"number":153,"title":"Calling unsubscribe() in transportFailure handler will not close all connections and client keeps trying to reconnect","user":{"login":"ookke","id":237161,"avatar_url":"https://avatars.githubusercontent.com/u/237161?v=3","gravatar_id":"","url":"https://api.github.com/users/ookke","html_url":"https://github.com/ookke","followers_url":"https://api.github.com/users/ookke/followers","following_url":"https://api.github.com/users/ookke/following{/other_user}","gists_url":"https://api.github.com/users/ookke/gists{/gist_id}","starred_url":"https://api.github.com/users/ookke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ookke/subscriptions","organizations_url":"https://api.github.com/users/ookke/orgs","repos_url":"https://api.github.com/users/ookke/repos","events_url":"https://api.github.com/users/ookke/events{/privacy}","received_events_url":"https://api.github.com/users/ookke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-02-20T12:51:39Z","updated_at":"2015-02-20T13:47:38Z","closed_at":null,"body":"It seems that calling unsubscribe() in a transportFailure handler will not cancel all connections, atmosphere will go ahead and try to reconnect anyway. I would expect atmosphere to give up all attempts when I call unsubscribe().\r\n\r\nI can reproduce this with a offline app that is loaded from the appcache and the server not accepting any connections. I guess something goes wrong in the unsubscribe cleanup in the situation that the current connection attempt is not successfully established yet?\r\n\r\nConsole output from the client:\r\n```js\r\n WebSocket connection to 'wss://localhost/app/api/v1/notifications/?X-Atmosphere-tracking-id=0…e-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED\r\napp.js:68429 Fri Feb 20 2015 14:40:37 GMT+0200 (FLE Standard Time) Atmosphere: websocket.onerror\r\napp.js:68429 Fri Feb 20 2015 14:40:37 GMT+0200 (FLE Standard Time) Atmosphere: websocket.onclose\r\napp.js:68429 Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent).\r\napp.js:68429 Websocket closed, wasClean: false\r\napp.js:68429 Fri Feb 20 2015 14:40:37 GMT+0200 (FLE Standard Time) Atmosphere: Firing onClose\r\napp.js:68429 Fri Feb 20 2015 14:40:37 GMT+0200 (FLE Standard Time) Atmosphere: Closed but not firing onClose\r\napp.js:68429 Websocket failed. Downgrading to Comet and resending\r\n\r\n//transport failure fires here and we call socket.unsubscribe(), however atmosphere keeps going inifinitely with reconnects\r\n\r\napp.js:68429 Closing\r\napp.js:68429 Fri Feb 20 2015 14:41:23 GMT+0200 (FLE Standard Time) Atmosphere: Closed but not firing onClose\r\napp.js:68429 Fri Feb 20 2015 14:41:23 GMT+0200 (FLE Standard Time) Atmosphere: Closed but not firing onClose\r\napp.js:67299 GET https://localhost/app/api/v1/notifications/?X-Atmosphere-tracking-id…=true&Content-Type=application%2Fjson&X-atmo-protocol=true&_=1424436089000 net::ERR_CONNECTION_REFUSED\r\napp.js:68429 Fri Feb 20 2015 14:41:29 GMT+0200 (FLE Standard Time) Atmosphere: ajaxRequest.onreadystatechange, new state: 4\r\napp.js:68429 Fri Feb 20 2015 14:41:29 GMT+0200 (FLE Standard Time) Atmosphere: ajaxrequest.onerror\r\napp.js:68429 Fri Feb 20 2015 14:41:29 GMT+0200 (FLE Standard Time) Atmosphere: Firing onReconnect\r\napp.js:68429 Fri Feb 20 2015 14:41:29 GMT+0200 (FLE Standard Time) Atmosphere: Firing onReconnect\r\napp.js:34616 POST https://localhost/app/api/v1/log net::ERR_CONNECTION_REFUSED\r\napp.js:67299 GET https://localhost/app/api/v1/notifications/?X-Atmosphere-tracking-id…=true&Content-Type=application%2Fjson&X-atmo-protocol=true&_=1424436090029 net::ERR_CONNECTION_REFUSED\r\napp.js:68429 Fri Feb 20 2015 14:41:30 GMT+0200 (FLE Standard Time) Atmosphere: ajaxRequest.onreadystatechange, new state: 4\r\napp.js:68429 Fri Feb 20 2015 14:41:30 GMT+0200 (FLE Standard Time) Atmosphere: ajaxrequest.onerror\r\napp.js:68429 Fri Feb 20 2015 14:41:30 GMT+0200 (FLE Standard Time) Atmosphere: Firing onReconnect\r\napp.js:68429 Fri Feb 20 2015 14:41:30 GMT+0200 (FLE Standard Time) Atmosphere: Firing onReconnect\r\napp.js:67299 GET https://localhost/app/api/v1/notifications/?X-Atmosphere-tracking-id…=true&Content-Type=application%2Fjson&X-atmo-protocol=true&_=1424436091114 net::ERR_CONNECTION_REFUSED\r\napp.js:68429 Fri Feb 20 2015 14:41:32 GMT+0200 (FLE Standard Time) Atmosphere: ajaxRequest.onreadystatechange, new state: 4\r\napp.js:68429 Fri Feb 20 2015 14:41:32 GMT+0200 (FLE Standard Time) Atmosphere: ajaxrequest.onerror\r\napp.js:68429 Fri Feb 20 2015 14:41:32 GMT+0200 (FLE Standard Time) Atmosphere: Firing onReconnect\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Atmosphere/atmosphere-javascript/issues/comments/75239976","html_url":"https://github.com/Atmosphere/atmosphere-javascript/issues/153#issuecomment-75239976","issue_url":"https://api.github.com/repos/Atmosphere/atmosphere-javascript/issues/153","id":75239976,"user":{"login":"jfarcand","id":51285,"avatar_url":"https://avatars.githubusercontent.com/u/51285?v=3","gravatar_id":"","url":"https://api.github.com/users/jfarcand","html_url":"https://github.com/jfarcand","followers_url":"https://api.github.com/users/jfarcand/followers","following_url":"https://api.github.com/users/jfarcand/following{/other_user}","gists_url":"https://api.github.com/users/jfarcand/gists{/gist_id}","starred_url":"https://api.github.com/users/jfarcand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfarcand/subscriptions","organizations_url":"https://api.github.com/users/jfarcand/orgs","repos_url":"https://api.github.com/users/jfarcand/repos","events_url":"https://api.github.com/users/jfarcand/events{/privacy}","received_events_url":"https://api.github.com/users/jfarcand/received_events","type":"User","site_admin":false},"created_at":"2015-02-20T13:47:38Z","updated_at":"2015-02-20T13:47:38Z","body":"@ookke I'm not sure I understand what you are trying to do. Can you share a test case on Github?"}}