[99s-extend] timeout in cowboy loop handler
Loïc Hoguin
essen at ninenines.eu
Wed Oct 16 05:40:31 CEST 2013
Infinite is bad practice, yes. Infinite means some connections will
*never* be closed, eating FDs and memory for nothing.
I'm not sure why you want to receive messages, you could just use a
normal handler that asks for more data, sends it, ask for more data,
sends it, etc.
On 10/16/2013 05:31 AM, akonsu wrote:
> thanks for your help. suppose that I want to stream live audio. I do not
> know how long my audio program will be, and as I stream it, if I have a
> timeout, the server will just disconnect the user that listens to the
> audio in the browser. and the browser won't reconnect. Would you suggest
> the "right" way to implement something like that? Would infinite timeout
> suffice? or is it a bad practice? another type of handler maybe?
>
>
> 2013/10/15 Loïc Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>
> Yep. And it will also disconnect if the client sends too much. It
> has to disconnect and reconnect eventually, there's no way around it.
>
>
> On 10/16/2013 05:03 AM, akonsu wrote:
>
> so it will disconnect if the client only listens and sends
> nothing to
> the socket, correct?
>
>
> 2013/10/15 Loïc Hoguin <essen at ninenines.eu
> <mailto:essen at ninenines.eu> <mailto:essen at ninenines.eu
> <mailto:essen at ninenines.eu>>>
>
>
> The socket connected to the client.
>
> TCP isn't perfect, there is no way to be 100% sure the
> client is
> still connected, hence the timeout. If the client is still
> up you
> should make it reconnect.
>
>
> On 10/16/2013 04:55 AM, akonsu wrote:
>
> Hello,
>
> the documentation for `init` at
> http://ninenines.eu/docs/en/____cowboy/HEAD/manual/cowboy_____loop_handler
> <http://ninenines.eu/docs/en/__cowboy/HEAD/manual/cowboy___loop_handler>
>
>
> <http://ninenines.eu/docs/en/__cowboy/HEAD/manual/cowboy___loop_handler
> <http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_loop_handler>>
> says:
>
> The receive loop will run for a duration of up to Timeout
> milliseconds
> after it last received data from the socket, at which
> point it
> will stop
> and send a 204 No Content reply.
>
> What socket does it refer to? I had an impression that
> the loop
> handles
> erlang messages. Do these messages come through a
> socket (sorry
> about a
> trivial question, but I am new to erlang), and this is the
> socket that
> the docs talk about?
>
> The reason why I am asking is because I used to have a
> Timeout
> of 60000,
> and even though messages kept coming non stop, it still
> kept
> disconnecting after a minute, until I set Timeout to
> infinity.
>
> thanks
> Konstantin
>
>
> ___________________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu <mailto:Extend at lists.ninenines.eu>
> <mailto:Extend at lists.__ninenines.eu
> <mailto:Extend at lists.ninenines.eu>>
> http://lists.ninenines.eu:81/____listinfo/extend
> <http://lists.ninenines.eu:81/__listinfo/extend>
>
> <http://lists.ninenines.eu:81/__listinfo/extend
> <http://lists.ninenines.eu:81/listinfo/extend>>
>
>
>
> --
> Loďc Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
>
>
>
> --
> Loïc Hoguin
>
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
>
--
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu
More information about the Extend
mailing list