{"action":"created","issue":{"url":"https://api.github.com/repos/websockets/ws/issues/527","labels_url":"https://api.github.com/repos/websockets/ws/issues/527/labels{/name}","comments_url":"https://api.github.com/repos/websockets/ws/issues/527/comments","events_url":"https://api.github.com/repos/websockets/ws/issues/527/events","html_url":"https://github.com/websockets/ws/issues/527","id":93795140,"number":527,"title":"Server port stays in use after `close()` method call","user":{"login":"lonelyelk","id":20437,"avatar_url":"https://avatars.githubusercontent.com/u/20437?v=3","gravatar_id":"","url":"https://api.github.com/users/lonelyelk","html_url":"https://github.com/lonelyelk","followers_url":"https://api.github.com/users/lonelyelk/followers","following_url":"https://api.github.com/users/lonelyelk/following{/other_user}","gists_url":"https://api.github.com/users/lonelyelk/gists{/gist_id}","starred_url":"https://api.github.com/users/lonelyelk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lonelyelk/subscriptions","organizations_url":"https://api.github.com/users/lonelyelk/orgs","repos_url":"https://api.github.com/users/lonelyelk/repos","events_url":"https://api.github.com/users/lonelyelk/events{/privacy}","received_events_url":"https://api.github.com/users/lonelyelk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-07-08T13:52:05Z","updated_at":"2015-08-27T16:03:20Z","closed_at":null,"body":"It seems there is no way to tell, when server address and port are stopped being used:\r\n\r\n```javascript\r\nvar WebSocketServer = require('ws').Server;\r\nvar wss = new WebSocketServer({port:9000});\r\nwss.close();\r\nwss = new WebSocketServer({port:9000});\r\n```\r\n\r\nThis gives EADDRINUSE on both node v0.12.6 and iojs v2.3.3. If this is an asynchronous method, than there should be a callback but `wss.on('close', fn)` is never called.\r\n\r\nThe problem appears when trying to test something that requires creation of the same server in `beforeEach`."},"comment":{"url":"https://api.github.com/repos/websockets/ws/issues/comments/135478855","html_url":"https://github.com/websockets/ws/issues/527#issuecomment-135478855","issue_url":"https://api.github.com/repos/websockets/ws/issues/527","id":135478855,"user":{"login":"Eeems","id":1176979,"avatar_url":"https://avatars.githubusercontent.com/u/1176979?v=3","gravatar_id":"","url":"https://api.github.com/users/Eeems","html_url":"https://github.com/Eeems","followers_url":"https://api.github.com/users/Eeems/followers","following_url":"https://api.github.com/users/Eeems/following{/other_user}","gists_url":"https://api.github.com/users/Eeems/gists{/gist_id}","starred_url":"https://api.github.com/users/Eeems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eeems/subscriptions","organizations_url":"https://api.github.com/users/Eeems/orgs","repos_url":"https://api.github.com/users/Eeems/repos","events_url":"https://api.github.com/users/Eeems/events{/privacy}","received_events_url":"https://api.github.com/users/Eeems/received_events","type":"User","site_admin":false},"created_at":"2015-08-27T16:03:19Z","updated_at":"2015-08-27T16:03:19Z","body":"I'll take a closer look. You could also try throwing some console logging into there to see what happens to _closeServer"}}