<div dir="ltr">Answering my own here.<div>This is pretty simple actually: if the connection header of the clients is keep-alive, Cowboy will wait the timeout before killing the process, so obviously it isn't removed from the router.<br></div><div><br></div><div>Duh.</div><div><br></div><div>Best,</div><div>r.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 15, 2015 at 11:11 AM, Roberto Ostinelli <span dir="ltr"><<a href="mailto:roberto@widetag.com" target="_blank">roberto@widetag.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear list,<div>I am using cowboy to handle long lived http connections.</div><div><br></div><div>When a new connection is successful, I link a router process to it with erlang:link/1, which traps exits, so that when I receive the messageĀ {'EXIT', Pid, Reason} I can remove the connection reference from the router process. Pretty standard stuff.</div><div><br></div><div>After Cowboy's terminate/3 callback is called, I immediately see the log that the connection has been removed from the router process too.</div><div><br></div><div>However, in production I see that it can take almost 2 minutes from the moment the terminate/3 function was called, and the router receiving the {'EXIT', Pid, Reason}, which means that after exiting from the terminate/3 function the Cowboy process does not exit for almost 2 minutes:<br></div><div><br></div><div>2015-05-14 21:16:25.302 [debug] <0.1714.0>@myapp_device:terminate:180 Terminated robot request</div><div>[...]</div><div><div>2015-05-14 21:18:15.304 [info] <0.1717.0>@myapp_router:handle_info:157 Now offline</div></div><div><br></div><div>My question is: have you seen this before? Does this mean that the client is badly formed and is refusing to shutdown gracefully? If so, is there a way to close the socket abruptly instead?</div><div><br></div><div>Thank you,</div><div>r.</div></div>
</blockquote></div><br></div>