# Exception change with net/http in Ruby 187 PL 248/9

**URL:** <https://www.ruby-forum.com/t/exception-change-with-net-http-in-ruby-187-pl-248-9/183645>\
**Category:** Ruby\
**Created:** [February 18, 2010, 1:52am UTC](https://www.ruby-forum.com/t/exception-change-with-net-http-in-ruby-187-pl-248-9/183645 "2010-02-18T01:52:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mitch\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@Mitch\_W](https://www.ruby-forum.com/u/Mitch_W)\
**Post date:** [February 18, 2010, 1:52am UTC](https://www.ruby-forum.com/t/exception-change-with-net-http-in-ruby-187-pl-248-9/183645/1 "2010-02-18T01:52:50Z")

</div>

Ran into the following problem with net http in Ruby 187 pl248

require net/http.rb  
n = Net::HTTP.new(‘server-that-is-not-listening-on-port-eighty’)  
n.request\_head(‘/’)

Prior to this change:  
[http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25851](http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25851) the  
above code results in an:

Errno::ECONNREFUSED: Connection refused - connect(2)

After the change I receive:

NoMethodError: undefined method `closed?’ for nil:NilClass

From line 1060 of net/http.rb. It looks like the code was intended to  
close  
sockets in the event of an error, but it assumes the socket actually  
exists.

Can anyone else reproduce this issue?

–

- Mitch W.

- Software Engineer

- SocialcastÂ®

- 19 South Park

- San Francisco, CA 94107

- e: removed\_email\_address@domain.invalid

- p: 651.964.8521

- f: 801.348.4750

This e-mail may be privileged and/or confidential, and the sender does  
not  
waive any related rights and obligations. Any distribution, use or  
copying  
of this e-mail or the information it contains by other than an intended  
recipient is unauthorized. If you are unsure why this e-mail was sent to  
you, please advise me (by return e-mail or otherwise) immediately.

---

<div class="post-metadata">

**Author:** ![Mitch\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@Mitch\_W](https://www.ruby-forum.com/u/Mitch_W)\
**Post date:** [February 18, 2010, 3:22pm UTC](https://www.ruby-forum.com/t/exception-change-with-net-http-in-ruby-187-pl-248-9/183645/2 "2010-02-18T15:22:16Z")

</div>

Hi,

On Thu, Feb 18, 2010 at 6:19 AM, Mitch W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Errno::ECONNREFUSED: Connection refused - connect(2)  
> Can anyone else reproduce this issue?

Yes, I can reproduce.

Indeed, this looks like unintentional change to me and somewhat  
unintuitive. I think, you should file a report on Redmine for this or  
raise it on ruby-core mailing list.

---

<div class="post-metadata">

**Author:** ![Mitch\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@Mitch\_W](https://www.ruby-forum.com/u/Mitch_W)\
**Post date:** [February 18, 2010, 6:26pm UTC](https://www.ruby-forum.com/t/exception-change-with-net-http-in-ruby-187-pl-248-9/183645/3 "2010-02-18T18:26:41Z")

</div>

Thanks for taking the time to respond Hemant.

I’ve added a redmine ticket for it here  
[http://redmine.ruby-lang.org/issues/show/2758](http://redmine.ruby-lang.org/issues/show/2758)

On Thu, Feb 18, 2010 at 6:20 AM, hemant [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Prior to this change:
> 
> Indeed, this looks like unintentional change to me and somewhat  
> unintuitive. I think, you should file a report on Redmine for this or  
> raise it on ruby-core mailing list.

–

- Mitch W.

- Software Engineer

- SocialcastÂ®

- 19 South Park

- San Francisco, CA 94107

- e: removed\_email\_address@domain.invalid

- p: 651.964.8521

- f: 801.348.4750

This e-mail may be privileged and/or confidential, and the sender does  
not  
waive any related rights and obligations. Any distribution, use or  
copying  
of this e-mail or the information it contains by other than an intended  
recipient is unauthorized. If you are unsure why this e-mail was sent to  
you, please advise me (by return e-mail or otherwise) immediately.
