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

Connection Timeout #23

Open
STRML opened this issue Aug 10, 2018 · 4 comments
Open

Connection Timeout #23

STRML opened this issue Aug 10, 2018 · 4 comments

Comments

@STRML
Copy link
Contributor

STRML commented Aug 10, 2018

Would be great to have a feature to set a connectTimeout and have the native addon give up on connecting after that time. In the wild I've seen a complete hang after the first reconnect from which this adapter never recovers. Unfortunately I can't reproduce but it seems to happen if redis crashes unexpectedly and doesn't tear down the socket correctly.

I've implemented it partially on the JS side but this doesn't seem like the right approach - if the remote is simply slow to connect, the onConnect callback from the lagging connection will fire and you might get multiple connect events. So it seems best to do this in the native addon.

@shuckc
Copy link

shuckc commented Jun 14, 2019

hiredis supports this via. redisConnectWithTimeout so I will prepare a patch.

@h0x91b
Copy link
Owner

h0x91b commented Jun 14, 2019

Thanks

@shuckc
Copy link

shuckc commented Jun 21, 2019

Ah - redisConnectWithTimeout() doesn't use libuv, it's a plain old blocking/synchronous API in hiredis, exactly as this reporter figured out too redis/hiredis#290
So it's not that easy, since libuv has no built in api for adding a timeout to an async socket connection attempt. There is a 3rd party workaround on the libuv help issue list libuv/help#54 this would need tidying up and incorporating into hiredis first before we could use it. Similar discussion here joyent/libuv#1415

@h0x91b
Copy link
Owner

h0x91b commented Jun 21, 2019 via email

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