Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP IOError: Network is unreachable on windows #4050

Closed
ranjithdharmaraj opened this issue Aug 5, 2016 · 10 comments
Closed

SMTP IOError: Network is unreachable on windows #4050

ranjithdharmaraj opened this issue Aug 5, 2016 · 10 comments

Comments

@ranjithdharmaraj
Copy link

ranjithdharmaraj commented Aug 5, 2016

Environment

JRuby 9.0.4.0 on windows 7:

$ jruby -v
jruby 9.0.4.0 (2.2.2) 2015-11-12 b9fb7aa Java HotSpot(TM) 64-Bit Server VM 25.91-b15 on 1.8.0_91-b15 +jit [Windows 7-amd64]

$ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

$ rails -v
Rails 4.2.6

Expected Behavior

$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]

$ irb
irb(main):001:0> RUBY_DESCRIPTION
=> "ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]"
irb(main):002:0> require 'net/smtp'
=> true
irb(main):003:0> smtp = Net::SMTP.new("xx.xxx.xxx.xxx", 25)
=> #<Net::SMTP xx.xxx.xxx.xxx:25 started=false>
irb(main):004:0> smtp.start
=> #<Net::SMTP xx.xxx.xxx.xxx started=true>
irb(main):005:0> RUBY_PLATFORM
=> "x64-mingw32"
irb(main):006:0>

Actual Behavior

irb(main):002:0> require 'net/smtp'
=> true
irb(main):003:0> smtp = Net::SMTP.new("xx.xxx.xxx.xxx", 25)
=> #<Net::SMTP xx.xxx.xxx.xxx:25 started=false>
irb(main):004:0> smtp.start
IOError: Network is unreachable: no further information
from org/jruby/ext/socket/RubyTCPSocket.java:138:in initialize' from org/jruby/RubyIO.java:1123:inopen'
from C:/Rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/smtp.rb:541:in tcp_socket' from C:/Rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/smtp.rb:551:inblock in do_start'
from org/jruby/ext/timeout/Timeout.java:147:in timeout' from C:/Rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/smtp.rb:550:indo_start'
from C:/Rubies/jruby-9.0.4.0/lib/ruby/stdlib/net/smtp.rb:526:in start' from (irb):4:in'
from org/jruby/RubyKernel.java:978:in eval' from org/jruby/RubyKernel.java:1291:inloop'
from org/jruby/RubyKernel.java:1098:in catch' from org/jruby/RubyKernel.java:1098:incatch'
from C:/Rubies/jruby-9.0.4.0/lib/ruby/gems/shared/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in start' from C:/Rubies/jruby-9.0.4.0/lib/ruby/gems/shared/gems/railties-4.2.6/lib/rails/commands/console.rb:9:instart'
from C:/Rubies/jruby-9.0.4.0/lib/ruby/gems/shared/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in console' from C:/Rubies/jruby-9.0.4.0/lib/ruby/gems/shared/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:inrun_command!'
from C:/Rubies/jruby-9.0.4.0/lib/ruby/gems/shared/gems/railties-4.2.6/lib/rails/commands.rb:17:in <top>' from org/jruby/RubyKernel.java:939:inrequire'
from bin/rails:4:in `'irb(main):005:0>

@headius
Copy link
Member

headius commented Aug 11, 2016

Perhaps you can try a newer build? JRuby 9.1.0.0 updated stdlib to Ruby 2.3 level, which might have fixed something.

Do you have an unusual network configuration on that system? This is an odd thing to fail only on Windows.

@ranjithdharmaraj
Copy link
Author

ranjithdharmaraj commented Aug 16, 2016

Apologies for the delay. I tried with jruby 9.1.2.0 (2.3.0) and get the same issue. There is nothing unusual about the network config as it works perfectly fine with MRI.

$ jruby -v
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.91-b15 on 1.8.0_91-b15 +jit [mswin32-x86_64]

$ irb
irb(main):001:0> require 'net/smtp'
=> true
irb(main):002:0> smtp = Net::SMTP.new('xx.xxx.xxx.xxx', 25)
=> #Net::SMTP xx.xxx.xxx.xxx:25 started=false>
irb(main):003:0> smtp.start
IOError: Network is unreachable: no further information
from org/jruby/ext/socket/RubyTCPSocket.java:138:in initialize' from org/jruby/RubyIO.java:1129:inopen'
from C:/Rubies/jruby-9.1.2.0/lib/ruby/stdlib/net/smtp.rb:542:in tcp_socket' from C:/Rubies/jruby-9.1.2.0/lib/ruby/stdlib/net/smtp.rb:552:inblock in do_start'
from org/jruby/ext/timeout/Timeout.java:149:in timeout' from C:/Rubies/jruby-9.1.2.0/lib/ruby/stdlib/net/smtp.rb:551:indo_start'
from C:/Rubies/jruby-9.1.2.0/lib/ruby/stdlib/net/smtp.rb:527:in start' from (irb):3:in'
from org/jruby/RubyKernel.java:983:in eval' from org/jruby/RubyKernel.java:1290:inloop'
from org/jruby/RubyKernel.java:1103:in catch' from org/jruby/RubyKernel.java:1103:incatch'
from C:/Rubies/jruby-9.1.2.0/bin/jirb:13:in `'
irb(main):004:0>

@headius
Copy link
Member

headius commented Aug 17, 2016

I don't have Windows handy at the moment...can you pass -Xbacktrace.style=full to JRuby and reproduce again?

@mprins
Copy link
Contributor

mprins commented Aug 18, 2016

this may be obvious, but since you didn't metntion.. did you check your firewall and virus scanner config that they allow java to open smtp sessions? those would normally be blocked.

@headius
Copy link
Member

headius commented Aug 19, 2016

I'll try to repro on Windows now that I have my VM working again.

@headius
Copy link
Member

headius commented Aug 19, 2016

I was unable to reproduce on my Windows 7 VM :-(

C:\Users\headius\jruby (jruby-9.1.2.0)
λ jruby --dev -rnet/smtp -e "smtp = Net::SMTP.new('smtp-relay.gmail.com', 25); smtp.start; puts smtp"
#<Net::SMTP:0x8519cb4>

We're willing to help you sort out the problem, but at the moment I have no way to reproduce what you're seeing.

@ranjithdharmaraj
Copy link
Author

So it looks like an environment issues on my side then. I tried adding exceptions to the windows firewall for java (all tcp connections were already allowed) but that did not help. I'll keep digging around.

@headius
Copy link
Member

headius commented Aug 24, 2016

@ranjithdharmaraj We'll close this for now. If you're able to determine it's a JRuby issue, feel free to reopen.

@headius headius closed this as completed Aug 24, 2016
@headius headius added this to the Invalid or Duplicate milestone Aug 24, 2016
@ranjithdharmaraj
Copy link
Author

@headius @mprins This was an IPv6 issue. I had to set the IPv4 (-J-Djava.net.preferIPv4Stack) option to true and it worked. Just thought will update the issue as it might be of help. Thanks for your help.

$ jruby --dev -rnet/smtp -e "smtp = Net::SMTP.new('xxx.xxx.xxx.xxx', 25); smtp.start; puts smtp"
IOError: Network is unreachable: no further information
initialize at org/jruby/ext/socket/RubyTCPSocket.java:138
open at org/jruby/RubyIO.java:1123
tcp_socket at C:/JAVA/APPS/JRUBY/jruby-9.0.4.0/lib/ruby/stdlib/net/smtp.rb:541
block in do_start at C:/JAVA/APPS/JRUBY/jruby-9.0.4.0/lib/ruby/stdlib/net/smtp.rb:551
timeout at org/jruby/ext/timeout/Timeout.java:147
do_start at C:/JAVA/APPS/JRUBY/jruby-9.0.4.0/lib/ruby/stdlib/net/smtp.rb:550
start at C:/JAVA/APPS/JRUBY/jruby-9.0.4.0/lib/ruby/stdlib/net/smtp.rb:526
at -e:1

$ jruby -J-Djava.net.preferIPv4Stack=true --dev -rnet/smtp -e "smtp = Net::SMTP.new('xxx.xxx.xxx.xxx', 25); smtp.start; puts smtp"
#Net::SMTP:0x194bcebf

@headius
Copy link
Member

headius commented Sep 13, 2016

@ranjithdharmaraj Thank you for the follow up! I'm glad to hear it was something simple and not JRuby's fault.

I've added a FAQ about this: https://github.com/jruby/jruby/wiki/FAQs#networking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants