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

[suggestions] - please add support for disconnect / connection timeout #53

Closed
ghost opened this issue May 5, 2018 · 2 comments
Closed

Comments

@ghost
Copy link

ghost commented May 5, 2018

for example, if you do

puts "Connecting to Redis..."
begin
    redis = Redis.new
    puts "Connected to Redis: #{redis}"
rescue e
  abort "Failed to connect to Redis Server: #{e}"
end

the user will never get a raised error about failed to connect. in fact, the above code will block (unless u put it into a fiber)

my suggestion:

  • let us give a connectiontimeout to the parameter, and after xxx seconds if no connection, it will raise an error.
  • if the master redis server dies, it should throw an error as well
  • if the wrong password is given (or no password, but redis requires one), raise an error as well

ty for your time

@ghost ghost changed the title please add support for disconnect / connection timeout [suggestions] - please add support for disconnect / connection timeout May 5, 2018
@stefanwille
Copy link
Owner

Should not be too difficult:

TCPSocket.new(host, port, dns_timeout = nil, connect_timeout = nil)

@ghost
Copy link
Author

ghost commented May 6, 2018

@stefanwille i added
tcpsocket = TCPSocket.new(host, port, false, 1)

to line 16, in connection.cr. and the redis error "connection timeout" dose get raised. =]

i am very new to crystal, so please take my ideas/posts with grain of salt. i'm still learning the ropes, thank you sir. great repo.

e: btw, im on Windows 10 using WSL. if that helps

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

1 participant