[ioredis] Unhandled error event: Error: connect ETIMEDOUT

created at 12-05-2021 views: 207


The redis initialization in the previous project was processed by the @Init decorator. After the configuration center is online recently, the configuration will be unified to the configuration center to obtain.

reason and solution

**@Init** can no longer be used, because it is acquired before the remote configuration, redis initialization must be changed to the completion of the remote configuration acquisition.

Occasionally, it will report [ioredis] Unhandled error event: Error: connect ETIMEDOUT. Some articles say that connectTimeout should be set to 10000, but after checking the document, the default setting is like this. So unreasonable.

After reading the document, I found that lazyConnect is set to true and no more errors are reported.

all done!

created at:12-05-2021
edited at: 12-05-2021: