Open arifinoid opened 4 years ago
<img src="https://i.ibb.co/qxG2GkF/Screen-Shot-2020-09-21-at-09-51-41.png" alt="postman-timeout"/>
<img src="https://i.ibb.co/2MPNW9j/Screen-Shot-2020-09-21-at-09-52-05.png" alt="code"/>
I am also running into this issue where a failure to connect just hangs requests. This has happened with all of the combinations of connection patterns I can think of:
I replicate this issue by simply not having redis running and the debug logs DEBUG=ioredis*
produce:
> conn = new Redis({ port: 6379, host: 'localhost', lazyConnect:true });
> conn.connect().then(console.log).catch(console.error)
ioredis:redis status[localhost:6379]: wait -> connecting +2m
ioredis:redis status[127.0.0.1:6379]: connecting -> connect +2ms
ioredis:redis write command[127.0.0.1:6379]: 0 -> info([]) +1ms
# Wait a long time
> conn.status
'connect'
I would definitely like to see the connection error propagate out to the caller, otherwise I am having to build my own connect timeout behaviour.
One poor workaround is to set enableOfflineQueue: false
on the instance. In this case if you send any command while the connection isn't working they will immediately error:
Error: Stream isn't writeable and enableOfflineQueue options is false
at Redis.sendCommand (/Users/stephenlewchuk/span/cloud/packages/app-api/node_modules/ioredis/built/redis/index.js:634:24)
at Redis.set (/Users/stephenlewchuk/span/cloud/packages/app-api/node_modules/ioredis/built/commander.js:111:25)
at repl:1:6
This does prevent the usage of lazy connect requiring you to manage connection on your own.
Currently me and my friend works as a team on a project that use redis and websocket to handle download request from client. But we faced a problem on server side after we deploy it on production (live). We got unhandled error event: Error: read ETIMEDOUT when we tried to get jwt in session for authenticating stuff, and then we stuck on that state. Here is the SS and Sample code:
auth.js
cache.js
Any suggestions / tips for this situation ?? we are very grateful if there is any help from you. Thank you