[99s-extend] timeout in cowboy loop handler

Loïc Hoguin essen at ninenines.eu
Wed Oct 16 06:48:05 CEST 2013


Then use a loop handler, set its timeout to infinity *but* create a new 
timeout that checks regularly if the handler is active or not to be able 
to kill it off in case something happens.

On 10/16/2013 06:42 AM, akonsu wrote:
> ok. the data that I need to send are coming as erlang messages to the
> process that runs my handler. so it sounds like if I want to use the
> "normal" cowboy_http_handler, then I need a receive loop
> inside handle(Req, State) callback, right? Basically, my response stream
> will potentially never end, I do not know how to handle this properly in
> cowboy...
>
>
> 2013/10/16 Loïc Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>
>     Loop handlers are designed to wait for a long time with the socket
>     *idle* and then eventually send one response then close the socket.
>     Things like long-polling.
>
>     What you are doing is just streaming, for which you do not need a
>     timeout because the socket isn't idle. You are just sending a large
>     response, and normal handlers are perfectly capable of doing that.
>


-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the Extend mailing list