{"action":"opened","issue":{"url":"https://api.github.com/repos/zettajs/zetta/issues/156","labels_url":"https://api.github.com/repos/zettajs/zetta/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/zettajs/zetta/issues/156/comments","events_url":"https://api.github.com/repos/zettajs/zetta/issues/156/events","html_url":"https://github.com/zettajs/zetta/issues/156","id":58582462,"number":156,"title":"Peers timing out are left in the api and JS object in http_server.js","user":{"login":"AdamMagaluk","id":823985,"avatar_url":"https://avatars.githubusercontent.com/u/823985?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamMagaluk","html_url":"https://github.com/AdamMagaluk","followers_url":"https://api.github.com/users/AdamMagaluk/followers","following_url":"https://api.github.com/users/AdamMagaluk/following{/other_user}","gists_url":"https://api.github.com/users/AdamMagaluk/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamMagaluk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamMagaluk/subscriptions","organizations_url":"https://api.github.com/users/AdamMagaluk/orgs","repos_url":"https://api.github.com/users/AdamMagaluk/repos","events_url":"https://api.github.com/users/AdamMagaluk/events{/privacy}","received_events_url":"https://api.github.com/users/AdamMagaluk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-23T13:00:41Z","updated_at":"2015-02-23T13:00:41Z","closed_at":null,"body":"Digging in to why in certain cases a peer that is disconnected still appears in the api i found that when a peer times out by our internal peer ping timer in peer_socket.js it is not properly closed.\r\n\r\nThe only way I found to reproduce this is to start a zetta server in the cloud then peer to on the local machine. Then turn off wifi. If you use another computer or phone to check the api in the cloud the peer says it still is connected.\r\n\r\nIn the code we are calling .close on the websocket when a timeout happens but closing the websocket does not make the underlying socket emit `error` or `end` which is what we are looking for. I have a branch where i'm manually emitting a PeerSocket `error` which http_server is listening for."}}