{"action":"created","issue":{"url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2551","repository_url":"https://api.github.com/repos/sandstorm-io/sandstorm","labels_url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2551/labels{/name}","comments_url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2551/comments","events_url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2551/events","html_url":"https://github.com/sandstorm-io/sandstorm/issues/2551","id":176994619,"number":2551,"title":"half-open TCP connections from `IpNetwork` and `IpInterface` are not handled correctly","user":{"login":"dwrensha","id":495768,"avatar_url":"https://avatars.githubusercontent.com/u/495768?v=3","gravatar_id":"","url":"https://api.github.com/users/dwrensha","html_url":"https://github.com/dwrensha","followers_url":"https://api.github.com/users/dwrensha/followers","following_url":"https://api.github.com/users/dwrensha/following{/other_user}","gists_url":"https://api.github.com/users/dwrensha/gists{/gist_id}","starred_url":"https://api.github.com/users/dwrensha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwrensha/subscriptions","organizations_url":"https://api.github.com/users/dwrensha/orgs","repos_url":"https://api.github.com/users/dwrensha/repos","events_url":"https://api.github.com/users/dwrensha/events{/privacy}","received_events_url":"https://api.github.com/users/dwrensha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-14T19:13:37Z","updated_at":"2016-09-30T13:40:38Z","closed_at":null,"body":"On IRC, @zenhack [reported](https://botbot.me/freenode/sandstorm/2016-09-13/?msg=72988388&page=3) that TCP connections from grains do not always close when expected. It looks like the problem is that we're registering callbacks for the \"close\" event when we should actually be registering callbacks for the [\"end\" event](https://nodejs.org/api/stream.html#stream_event_end):\r\n\r\nhttps://github.com/sandstorm-io/sandstorm/blob/v0.185/shell/server/drivers/ip.js#L328-L330\r\nhttps://github.com/sandstorm-io/sandstorm/blob/v0.185/shell/server/drivers/ip.js#L55-L57\r\n\r\nWe should also write tests to verify that the implementations have the correct behavior on half-open sockets.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/comments/250746886","html_url":"https://github.com/sandstorm-io/sandstorm/issues/2551#issuecomment-250746886","issue_url":"https://api.github.com/repos/sandstorm-io/sandstorm/issues/2551","id":250746886,"user":{"login":"dwrensha","id":495768,"avatar_url":"https://avatars.githubusercontent.com/u/495768?v=3","gravatar_id":"","url":"https://api.github.com/users/dwrensha","html_url":"https://github.com/dwrensha","followers_url":"https://api.github.com/users/dwrensha/followers","following_url":"https://api.github.com/users/dwrensha/following{/other_user}","gists_url":"https://api.github.com/users/dwrensha/gists{/gist_id}","starred_url":"https://api.github.com/users/dwrensha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwrensha/subscriptions","organizations_url":"https://api.github.com/users/dwrensha/orgs","repos_url":"https://api.github.com/users/dwrensha/repos","events_url":"https://api.github.com/users/dwrensha/events{/privacy}","received_events_url":"https://api.github.com/users/dwrensha/received_events","type":"User","site_admin":false},"created_at":"2016-09-30T13:40:38Z","updated_at":"2016-09-30T13:40:38Z","body":"I have been unable to reproduce this problem. My hypothesis was that the socket created [here](https://github.com/sandstorm-io/sandstorm/blob/v0.185/shell/server/drivers/ip.js#L319) would fail to emit an \"close\" event if it ended up in a half-closed state, but apparently in Node [`allowHalfOpen`](https://nodejs.org/api/net.html#net_event_end) is `false` by default, so Node should be fulling closing the socket. I tried various experiments and the only way I could prevent an \"end\" event being emitted without a corresponding \"close\" event was by explicitly setting `allowHalfOpen` to `true`.\r\n\r\n@zenhack: are you able to reliably reproduce the problem? Can you construct an isolated test case?\r\n\r\n"}}
{"actor":{"display_login":"dwrensha"}}