[racket] Web server: Disable timeout?

From: Tom McNulty (tom.mcnulty at gmail.com)
Date: Fri Mar 30 00:56:49 EDT 2012

Michael, perhaps you're interested in Web Sockets.  They're a better fit for what you're trying to accomplish.  http://docs.racket-lang.org/net/websocket.html?q=websocket

Alternatively, you might try to implement a COMET service, and use long-polling.  This is a hack to emulate web socket style two-way communication. 

On 2012-03-29, at 7:18 PM, Michael W wrote:

> So is it possible to disable the timeout on the web server? Or is
> this a /very bad idea/?
> 
> Right now I'm constructing my own dispatcher chain with the
> low-level server API. My intent is to build a streaming HTTP
> service similar to the Twitter streaming API that will send a
> short one-line message to connected clients every few seconds
> forever. The server insists on timing out after a minute or so.
> 
> Try this example. Run
> 
> curl http://localhost:8080/foo
> 
> and watch the clock count up.
> 
> This certainly isn't very idiomatic, but I don't want the
> namespace-isolation shenanigans that servlets enforce. Is there a
> better way?
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> #lang racket
> 
> (require web-server/web-server
>         web-server/http
>         (only-in web-server/dispatchers/dispatch-pathprocedure [make path]))
> 
> (serve
> #:listen-ip #f
> #:port 8080
> #:dispatch
> (path "/foo"
>       (λ(request)
>         (response
>          200 #"OK"
>          (current-seconds) TEXT/HTML-MIME-TYPE
>          (list)
>          (λ(op)
>            (let loop ([i 0])
>              (fprintf op "~a\n" i)
>              (flush-output op)
>              (sleep 1)
>              (loop (add1 i))))))))
> 
> (do-not-return)
> 
> 
> -- 
> Onward,
>    _mike
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.racket-lang.org/users/archive/attachments/20120329/cbb5f742/attachment.sig>

Posted on the users mailing list.