# Net:HTTP Timeout Bug

**URL:** <https://www.ruby-forum.com/t/net-http-timeout-bug/177729>\
**Category:** Ruby\
**Created:** [October 22, 2009, 6:12pm UTC](https://www.ruby-forum.com/t/net-http-timeout-bug/177729 "2009-10-22T18:12:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [October 22, 2009, 6:12pm UTC](https://www.ruby-forum.com/t/net-http-timeout-bug/177729/1 "2009-10-22T18:12:16Z")

</div>

When I do an HTTP get on a URL that doesn’t exist using NET:HTTP, the  
read\_timeout value is ignored and the connection stays open forever.  
I read somewhere that this is a known bug (Bug #949) but I was trying to  
do a work around to close the connection.

I tried using http.finish as is shown in the Class description but this  
won’t force the connection closed.

Can anyone help me out with a way to force an NET::HTTP connection  
closed?

thanks in advance

Jackster

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [October 24, 2009, 1:08am UTC](https://www.ruby-forum.com/t/net-http-timeout-bug/177729/2 "2009-10-24T01:08:12Z")

</div>

jackster the jackle wrote:

> When I do an HTTP get on a URL that doesn’t exist using NET:HTTP, the  
> read\_timeout value is ignored and the connection stays open forever.  
> I read somewhere that this is a known bug (Bug #949) but I was trying to  
> do a work around to close the connection.
> 
> I tried using http.finish as is shown in the Class description but this  
> won’t force the connection closed.
> 
> Can anyone help me out with a way to force an NET::HTTP connection  
> closed?

appears that applying something like

r25097 and r25098 for Ruby 1.8 & 1.9

should do it?  
-r

[http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/http.rb?r1=25097&r2=25096&pathrev=25097](http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/http.rb?r1=25097&r2=25096&pathrev=25097)
