title: How to set timeout for Net::HTTP.start?
body: <p>Im having trouble where the host that im trying to connect to isn't always avaible. 
  Im using this bit of code where im connecting to the host:</p>
  
  <pre><code>begin #To catch error from Net::HTTP
  net = Net::HTTP.new(uri.host, uri.port)
  net.read_timeout = 5
  net.continue_timeout = 5
  res = net.start {|http|
      http_request = http.request(req)
      case http_request.response 
          case
              ...
          else
              @error_msg = "Response not handled by appliaction" &lt;&lt; http_request.code &lt;&lt; " " &lt;&lt; http_request.message 
      end 
  }
  rescue SocketError =&gt; se 
      @error_msg = "Net::SocketError #{se} (Perhaps host is down?)"
      puts @error_msg
  end
  </code></pre>
  
  <p>The problem is when the host isnt responding (or something else is wrong) the connection seem to be running way to long. i was hoping for a 5 second wait, 
  but its trying for way to long:</p>
  
  <pre><code>Completed 500 Internal Server Error in 126302ms
  Errno::ETIMEDOUT - Connection timed out - connect(2):
  </code></pre>
  
  <p>How do i set the maximum timeout for a Net:HTTP object? </p>
  
  <p>Thanks</p>