redis / hiredis-rb

Ruby wrapper for hiredis
BSD 3-Clause "New" or "Revised" License
319 stars 90 forks source link

Ruby Fallback Gives Socket Error on Windows #56

Open lynnfaraday opened 5 years ago

lynnfaraday commented 5 years ago

I know that the hiredis extension is not supported on Windows, but I thought it was supposed to fall back to a pure Ruby implementation. It seems that does not work either on Windows - is that intentional?

require "redis"
require "hiredis"
require "hiredis/ruby/connection"

conn = Hiredis::Ruby::Connection.new
conn.connect("127.0.0.1", "6379", 10000)
conn.write(["PING"])
p conn.read

ruby hi-test.rb:

<internal:prelude>:78:in `__read_nonblock': A non-blocking socket operation could not be completed immediately. - read would block (IO::EWOULDBLOCKWaitReadable)
        from <internal:prelude>:78:in `read_nonblock'
        from C:/tools/ruby24/lib/ruby/gems/2.4.0/gems/hiredis-0.6.1/lib/hiredis/ruby/connection.rb:268:in `read'
        from ./hi-test.rb:6:in `<main>'

Interestingly, those exact same commands work OK when used manually in IRB, so it seems like this could be made to work on Windows. Perhaps there's a timing issue?

PS C:\WINDOWS\system32> irb
irb(main):001:0> require 'hiredis/ruby/connection'
=> true
irb(main):002:0> conn = Hiredis::Ruby::Connection.new
=> #<Hiredis::Ruby::Connection:0x00000000038a0428 @sock=nil, @timeout=nil>
irb(main):003:0> conn.connect("127.0.0.1", "6379", 10000)
=> nil
irb(main):004:0> conn.write(["PING"])
=> nil
irb(main):005:0> p conn.read
"PONG"
=> "PONG"
=> "awesome"

Running redis 3.0.503, redis gem 4.1.0, hiredis gem 0.6.3.