Last active
August 29, 2015 13:56
-
-
Save fukayatsu/8817319 to your computer and use it in GitHub Desktop.
MacOSX(10.9.1 configure ipv6: automatically) + Ruby(2.1.0) + redis-rb(3.0.7) + localhost => crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fk82% ruby -v | |
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0] | |
fk82% irb -rredis | |
irb(main):001:0> Redis::VERSION | |
=> "3.0.7" | |
irb(main):002:0> redis = Redis.new(host: 'fe80::1%lo0') | |
=> #<Redis client v3.0.7 for redis://fe80::1%lo0:6379/0> | |
irb(main):003:0> irb(main):003:0> redis.get 'foo' | |
Users/fukayatsu/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.0.7/lib/redis/connection/ruby.rb:129: [BUG] rb_sys_fail_str(connect(2) for [fe80::1%lo0]:6379) - errno == 0 | |
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0] | |
-- Crash Report log information -------------------------------------------- | |
See Crash Report log file under the one of following: | |
* ~/Library/Logs/CrashReporter | |
* /Library/Logs/CrashReporter | |
* ~/Library/Logs/DiagnosticReports | |
* /Library/Logs/DiagnosticReports | |
for more details. | |
-- Control frame information ----------------------------------------------- | |
c:0041 p:---- s:0160 e:000159 CFUNC :connect_nonblock | |
c:0040 p:0062 s:0156 e:000155 BLOCK /Users/fukayatsu/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.0.7/lib/redis/connection/ruby.rb:129 | |
c:0039 p:0071 s:0153 e:000152 METHOD /Users/fukayatsu/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.0.7/lib/redis/connection/ruby.rb:121 | |
c:0038 p:0015 s:0145 e:000144 BLOCK /Users/fukayatsu/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/redis-3.0.7/lib/redis/connection/ruby.rb:162 [FINISH] | |
.... | |
fk82% ruby -v | |
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] | |
fk82% irb -rredis | |
irb(main):001:0> Redis::VERSION | |
=> "3.0.7" | |
irb(main):002:0> redis = Redis.new(host: 'fe80::1%lo0') | |
=> #<Redis client v3.0.7 for redis://fe80::1%lo0:6379/0> | |
irb(main):003:0> redis.get 'foo' | |
Redis::CannotConnectError: Error connecting to Redis on fe80::1%lo0:6379 (ECONNREFUSED) | |
解決方法
Redis.new(host: 'localhost')
=>Redis.new(host: '127.0.0.1')
orRedis.new
OR
- configure ipv6: automatically => link-local only
related:
Don't hardcode Ruby connection to IPv4 by pietern · Pull Request #394 · redis/redis-rb
redis/redis-rb#394
Bug #9352: [BUG] rb_sys_fail_str(connect(2) for [fe80::1%lo0]:3000) - errno == 0 - ruby-trunk - Ruby Issue Tracking System
https://bugs.ruby-lang.org/issues/9352
Hello,
I got this bug using locahost. I replaced by 127.0.0.1 and it works fine.
nice :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MacOSXのネットワーク設定でconfigure ipv6: automaticallyにしてると、RubyでSocket.getaddrinfo("localhost", nil)したときに"::1"が最初に返ってくるので、Ruby2.1.0でRedis.new(host: 'localhost')とかするとこんなクラッシュに遭遇することがある