summaryrefslogblamecommitdiffstats
path: root/archives/extend/2013-October/000280.html
blob: 24d9e1e38044f0027334fbebf0bdb2c3915c8058 (plain) (tree)


























































































                                                                                                                                                                                                                            
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
 <HEAD>
   <TITLE> [99s-extend] timeout in cowboy loop handler
   </TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20timeout%20in%20cowboy%20loop%20handler&In-Reply-To=%3C525E1A85.3070706%40ninenines.eu%3E">
   <META NAME="robots" CONTENT="index,nofollow">
   <style type="text/css">
       pre {
           white-space: pre-wrap;       /* css-2.1, curent FF, Opera, Safari */
           }
   </style>
   <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
   <LINK REL="Previous"  HREF="000279.html">
   <LINK REL="Next"  HREF="000281.html">
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[99s-extend] timeout in cowboy loop handler</H1>
    <B>Lo&#239;c Hoguin</B> 
    <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20timeout%20in%20cowboy%20loop%20handler&In-Reply-To=%3C525E1A85.3070706%40ninenines.eu%3E"
       TITLE="[99s-extend] timeout in cowboy loop handler">essen at ninenines.eu
       </A><BR>
    <I>Wed Oct 16 06:48:05 CEST 2013</I>
    <P><UL>
        <LI>Previous message: <A HREF="000279.html">[99s-extend] timeout in cowboy loop handler
</A></li>
        <LI>Next message: <A HREF="000281.html">[99s-extend] handler and a linked process
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#280">[ date ]</a>
              <a href="thread.html#280">[ thread ]</a>
              <a href="subject.html#280">[ subject ]</a>
              <a href="author.html#280">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>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:
&gt;<i> ok. the data that I need to send are coming as erlang messages to the
</I>&gt;<i> process that runs my handler. so it sounds like if I want to use the
</I>&gt;<i> &quot;normal&quot; cowboy_http_handler, then I need a receive loop
</I>&gt;<i> inside handle(Req, State) callback, right? Basically, my response stream
</I>&gt;<i> will potentially never end, I do not know how to handle this properly in
</I>&gt;<i> cowboy...
</I>&gt;<i>
</I>&gt;<i>
</I>&gt;<i> 2013/10/16 Lo&#239;c Hoguin &lt;<A HREF="https://lists.ninenines.eu/listinfo/extend">essen at ninenines.eu</A> &lt;mailto:<A HREF="https://lists.ninenines.eu/listinfo/extend">essen at ninenines.eu</A>&gt;&gt;
</I>&gt;<i>
</I>&gt;<i>     Loop handlers are designed to wait for a long time with the socket
</I>&gt;<i>     *idle* and then eventually send one response then close the socket.
</I>&gt;<i>     Things like long-polling.
</I>&gt;<i>
</I>&gt;<i>     What you are doing is just streaming, for which you do not need a
</I>&gt;<i>     timeout because the socket isn't idle. You are just sending a large
</I>&gt;<i>     response, and normal handlers are perfectly capable of doing that.
</I>&gt;<i>
</I>

-- 
Lo&#239;c Hoguin
Erlang Cowboy
Nine Nines
<A HREF="http://ninenines.eu">http://ninenines.eu</A>

</PRE>

<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI>Previous message: <A HREF="000279.html">[99s-extend] timeout in cowboy loop handler
</A></li>
	<LI>Next message: <A HREF="000281.html">[99s-extend] handler and a linked process
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#280">[ date ]</a>
              <a href="thread.html#280">[ thread ]</a>
              <a href="subject.html#280">[ subject ]</a>
              <a href="author.html#280">[ author ]</a>
         </LI>
       </UL>

<hr>
<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend
mailing list</a><br>
</body></html>