ioredis: Error: connect ETIMEDOUT ----use bluebird
I use bluebird replace native promise, error happened!
ioredis:redis status[172.31.15.99:5818]: [empty] -> connecting +0ms
ioredis:redis queue command[172.31.15.99:5818]: 2 -> set([ 'aaa', '1' ]) +5ms
ioredis:connection error: Error: connect ETIMEDOUT +0ms
redisClient connect to db error: { Error: connect ETIMEDOUT
at Socket.<anonymous> (/opt/project/umichat/umichat_manage/node_modules/_ioredis@4.14.1@ioredis/built/redis/index.js:282:31)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at Socket._onTimeout (net.js:422:8)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5) errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect' }
ioredis:redis status[172.31.15.99:5818]: connecting -> close +10s
ioredis:connection reconnect in 50ms +3ms
ioredis:redis status[172.31.15.99:5818]: close -> reconnecting +1ms
ioredis:redis status[172.31.15.99:5818]: reconnecting -> connecting +50ms
envriment:
node: v8.16.0
redis server: 5.0.5
ioredis: 4.14.1
bluebird: 3.5.5
my test code
const bluebird = require('bluebird');
global.Promise = bluebird;
const Redis = require('ioredis');
const instance = new Redis({
port: 6379,
host: 'localhost',
db: 2,
});
instance.on('error', e => {
console.error(`redisClient connect to db error:`, e);
});
instance.set("aaa", 1)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 19 (5 by maintainers)
Commits related to this issue
- Handle connection after connect event was emitted It's possible for connect promise to resolve after the resolved connection has already been established, which means we miss the connect event. This ... — committed to alavers/ioredis by alavers 4 years ago
- fix: handle connection after connect event was emitted (#1095) It's possible for connect promise to resolve after the resolved connection has already been established, which means we miss the connec... — committed to redis/ioredis by alavers 4 years ago
- chore(release): 4.16.2 [skip ci] ## [4.16.2](https://github.com/luin/ioredis/compare/v4.16.1...v4.16.2) (2020-04-11) ### Bug Fixes * dismiss security alerts for dev dependencies [skip release] ([75... — committed to redis/ioredis by semantic-release-bot 4 years ago
- Update package.json Let's see if we can fix the issue with the bluebird global promise and the stream trying to connect too fast and missing the exception. https://github.com/luin/ioredis/issues/977 — committed to andywelters/bull by andywelters 4 years ago
- chore(release): 4.16.2 [skip ci] ## [4.16.2](https://github.com/luin/ioredis/compare/v4.16.1...v4.16.2) (2020-04-11) ### Bug Fixes * dismiss security alerts for dev dependencies [skip release] ([75... — committed to janus-dev87/ioredis-work by janus-dev87 4 years ago
@alavers I’d think we can check if
streamhas already connected before attaching the listener to connect event (https://github.com/luin/ioredis/blob/master/lib/redis/index.ts#L307) so can be:Not sure if Node.js provides enough APIs for the
isConnectedmethod.you can tell whether a function wants a callback by the length of that function, no need to break the promise contract now