# Net-smtp timeout error

**URL:** <https://www.ruby-forum.com/t/net-smtp-timeout-error/158669>\
**Category:** Ruby\
**Created:** [January 26, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/net-smtp-timeout-error/158669 "2009-01-26T17:27:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [January 26, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/net-smtp-timeout-error/158669/1 "2009-01-26T17:27:43Z")

</div>

Hi,

Ruby 1.8.6-p114  
RHEL 3

I’ve got two RHEL3 boxes, alpha and beta. On the alpha box, the  
following script works fine. On the beta box I get a timeout error  
with the same script. What’s happening?

require ‘net/smtp’

host = ‘[mailhost.foo.com](http://mailhost.foo.com)’  
port = 25  
to = ‘removed\_email\_address@domain.invalid’  
from = ‘removed\_email\_address@domain.invalid’  
subject = ‘test’  
body = ‘hello world’

Net::SMTP.start(host, port, host){ |smtp|  
smtp.open\_message\_stream(from, to){ |stream|  
stream.puts “From: #{from}”  
stream.puts "To: " + to.to\_a.join(', ')  
stream.puts “Subject: #{subject}”  
stream.puts  
stream.puts body  
}  
}

Result:

/usr/local/lib/ruby/1.8/timeout.rb:54:in `new': execution expired (Timeout::Error) from /usr/local/lib/ruby/1.8/net/protocol.rb:206:in `old\_open’  
from /usr/local/lib/ruby/1.8/timeout.rb:56:in `timeout' from /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout’  
from /usr/local/lib/ruby/1.8/net/protocol.rb:206:in `old_open' from /usr/local/lib/ruby/1.8/net/smtp.rb:393:in `do\_start’  
from /usr/local/lib/ruby/1.8/net/smtp.rb:378:in `start' from /usr/local/lib/ruby/1.8/net/smtp.rb:316:in `start’  
from smtp\_test.rb:12

I did validate that the /etc/resolv.conf and /etc/protocols files were  
the same on both boxes.

This some sort of sendmail config issue? If so, any ideas what it  
might be?

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [January 27, 2009, 4:32am UTC](https://www.ruby-forum.com/t/net-smtp-timeout-error/158669/2 "2009-01-27T04:32:56Z")

</div>

Thibault wrote:

> telnet [mailhost.foo.com](http://mailhost.foo.com) 25
> 
> > This some sort of sendmail config issue? If so, any ideas what it  
> > might be?
> 
> I don’t think so, since you are using SMTP you’re bypassing your local  
> MTA.

It turns out there was a bad, hard coded mailhost value in the  
/etc/hosts file on the beta box. Odd.

Anyway, thanks for the reply and the suggestions.

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [January 26, 2009, 6:21pm UTC](https://www.ruby-forum.com/t/net-smtp-timeout-error/158669/3 "2009-01-26T18:21:51Z")

</div>

Hello,

On Mon, 26 Jan 2009 11:25:14 -0500, Daniel B. wrote:

> I’ve got two RHEL3 boxes, alpha and beta. On the alpha box, the  
> following script works fine. On the beta box I get a timeout error  
> with the same script. What’s happening?

I think you did a check without your script likeÂ :

nc [mailhost.foo.com](http://mailhost.foo.com) 25  
telnet [mailhost.foo.com](http://mailhost.foo.com) 25

If not I suggest you do so in order to check if your problem really  
comes from your script, or from a firewall, routing issueâ€¦

> I did validate that the /etc/resolv.conf and /etc/protocols files were  
> the same on both boxes.

Maybe you could also check with tcpdump to see if packets are  
sent/received as attended.

> This some sort of sendmail config issue? If so, any ideas what it  
> might be?

I don’t think so, since you are using SMTP you’re bypassing your local  
MTA.
