[erlang-questions] Cowboy and links: weird delayed times

Roberto Ostinelli <>
Fri May 15 11:33:28 CEST 2015


Answering my own here.
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.

Duh.

Best,
r.


On Fri, May 15, 2015 at 11:11 AM, Roberto Ostinelli <>
wrote:

> Dear list,
> I am using cowboy to handle long lived http connections.
>
> 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.
>
> After Cowboy's terminate/3 callback is called, I immediately see the log
> that the connection has been removed from the router process too.
>
> 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:
>
> 2015-05-14 21:16:25.302 [debug] <0.1714.0>@myapp_device:terminate:180
> Terminated robot request
> [...]
> 2015-05-14 21:18:15.304 [info] <0.1717.0>@myapp_router:handle_info:157 Now
> offline
>
> 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?
>
> Thank you,
> r.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150515/12681206/attachment.html>


More information about the erlang-questions mailing list