ioredis icon indicating copy to clipboard operation
ioredis copied to clipboard

commandTimeout option triggers Command timed out error after connecting to redis server

Open varuna-aample opened this issue 4 years ago • 2 comments

Hello, commandTimeout option set to 20ms throws out Error: Command timed out in my case. I have set event listeners set for connection events connect, ready (with enableReadyCheck=true), disconnect

  1. Error is thrown after the connect event,
  2. disconnect event is triggered after above error is thrown
  3. ioredis retries to connect, connect event is triggered
  4. Above 3 steps keep looping

I want the redis commands to timeout after 20ms hence I'm using commandTimeout

Can you please explain why command timeout error is triggered after connecting to the server if the timeout value is around 20ms? or am I missing something?

varuna-aample avatar Sep 13 '21 13:09 varuna-aample

20ms is quite low. are you sure about that? the ready check command probably times out as the initial connection and sending the command takes longer.

marcbachmann avatar May 23 '22 10:05 marcbachmann

Let's say the application has sent a GET command but there is a connection issue, I don't want the application to wait more than 20ms because most of my GET call latencies are under 5ms

But this command timeout is being applied while getting the connection itself and timing out (with ready check disabled).

Is there no way to exclude the command timeout while getting connection? or if there is a way to pass options as arguments for each command

varuna-aample avatar May 23 '22 11:05 varuna-aample