Re: timeout when acting as a cache proxy

LHERBIER Lois <[email protected]> Mon, 21 Feb 2005 09:04:22 +0100
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
hello,
you can change the mod_ruby timeout with the RubyTimeOut directive in 
the apache config file.
you can find the documentation here : 
http://modruby.net/en/doc/?ApacheDirectives#RubyTimeOut+sec
I hope that this will help.

   Loïs


Adeodato Simó wrote:

>Hello,
>  
>  I've written a small ruby cgi that acts as a proxy for file downloads.
>  If the requested file is in the cache, it's sent to the client
>  directly. If not, it is fetched from its remote location and it's sent
>  to the client at the same time (with req.read_body { block }).
>
>  A very simplified version of it follows; the downloaded file is large
>  enough that it takes more than 5min to be downloaded in my system.
>  When run as a CGI, all goes fine. When using modruby, however, I get
>  the following error exactly after 270 seconds:
>
>mod_ruby: /var/www/adeodato/cgi/timeout.rbx:5:in `rbuf_fill': timeout (270 sec) (Apache::TimeoutError)
>mod_ruby:   from /usr/lib/ruby/1.8/net/protocol.rb:196:in `timeout'
>mod_ruby:   from /usr/lib/ruby/1.8/timeout.rb:55:in `timeout'
>mod_ruby:   from /usr/lib/ruby/1.8/net/protocol.rb:196:in `rbuf_fill'
>mod_ruby:   from /usr/lib/ruby/1.8/net/protocol.rb:128:in `read'
>mod_ruby:   from /usr/lib/ruby/1.8/net/http.rb:1735:in `read_body_0'
>mod_ruby:   from /usr/lib/ruby/1.8/net/http.rb:1697:in `read_body'
>mod_ruby:   from /var/www/adeodato/cgi/timeout.rbx:17
>mod_ruby:   from /var/www/adeodato/cgi/timeout.rbx:15:in `request'
>mod_ruby:   from /usr/lib/ruby/1.8/net/http.rb:835:in `reading_body'
>mod_ruby:   from /usr/lib/ruby/1.8/net/http.rb:835:in `request'
>mod_ruby:   from /usr/lib/ruby/1.8/net/http.rb:823:in `request'
>mod_ruby:   from /usr/lib/ruby/1.8/net/http.rb:821:in `start'
>mod_ruby:   from /usr/lib/ruby/1.8/net/http.rb:821:in `request'
>mod_ruby:   from /usr/lib/ruby/1.8/net/http.rb:734:in `request_get'
>mod_ruby:   from /var/www/adeodato/cgi/timeout.rbx:15
>mod_ruby:   from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `load'
>mod_ruby:   from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler'
>
>  Is this a known behavior of modruby, and I should be just rescueing
>  timeouts, or there is a better solution. Perhaps something is wrong
>  with my code?
>
>  This is the script, thanks in advance:
>
>------------------------8<------------------------------------------------------
>#! /usr/bin/ruby -w
>
>require 'cgi'
>require 'uri'
>require 'net/http'
>
>Apache.request.sync_output = true if defined? MOD_RUBY
>
>file = "http://ftp.de.debian.org/debian/pool/main/o/openoffice.org/openoffice.org-bin_1.1.3-6_i386.deb"
>
>uri = URI.parse(file)
>
>http = Net::HTTP.new(uri.host, uri.port)
>
>http.request_get(uri.request_uri) do |r|
>  print CGI.new.header('Content-Length' => r['Content-Length'])
>  r.read_body { |seg|
>    print seg
>    # in the real cgi, I also do this:
>    # somefile.print seg
>  }
>end
>------------------------8<------------------------------------------------------
>
>  
>