CLIENT: 3.0.2
REDIS: 5.0.3
- Running within Docker / node:14.15.4-alpine3.12
- Running Inside GCLOUD ( latency ~10ms )
- After started, the app starts PINGING the redis server every 30 seconds
- Server crashes after 4 minutes (usually), just after PING #8 ( PING timestamp === ERROR timestamp )
- not a single event es registered in the log ( end, error, uncaughtException, reconnecting )
- I've tried ECHO instead of PING but I got same results.
var redis__create_ping = ( client ) => {
client.ping = setInterval(( )=>{
let timestamp = ( new Date() ).getTime();
client.instance.ping( (error, pong ) => {
if( error ){
console.error( '
<PING ERROR>', client.name, client.index );
console.error( error );
}
else {
if( __.DEBUG ){
console.log( '
<PING>', client.name, client.index, (new Date()).getTime() - timestamp );
}
};
});
}, 30000);
};
var redis__connect = ( args , success, fail ) => {
let { index, name } = args;
let client = { name, index };
let host = ___.REDIS.HOST;
let port = ___.REDIS.PORT;
let cli = redis.createClient({ host, port, db: index, socket_keepalive: true });
cli.on('connect', ready => {
if( __.DEBUG ) console.info('
<CONNECT>', name, index );
client.instance = cli;
redis__create_ping( client );
CLIENTS[name] = client;
success( true );
});
cli.on('ready', () => {
if( __.DEBUG ) console.info( '
<READY>', name, index );
});
cli.on('reconnecting', () => {
if( __.DEBUG ) console.info( '
<RECONNECTING>', name, index );
});
cli.on('end', () => {
if( __.DEBUG ) console.info('
<END>', name, index );
});
cli.on('uncaughtException', error => {
console.error('
<UNCAUGHT-EXCEPTION>', name, index );
console.error( error );
});
cli.on('error', error => {
console.error('
<ERROR>', name, index );
console.error( error );
});
};
LOG
...
2021-01-27 15:59:42.472 EST<PING> REDIS_CLIENT_BLOCKED_NUMBERS_WRITE 11 4
Default
2021-01-27 15:59:42.480 ESTevents.js:292
Default
2021-01-27 15:59:42.480 EST throw er; // Unhandled 'error' event
Default
2021-01-27 15:59:42.480 EST ^
Default
2021-01-27 15:59:42.480 EST
Default
2021-01-27 15:59:42.480 ESTError: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Default
2021-01-27 15:59:42.480 ESTEmitted 'error' event on RedisClient instance at:
Default
2021-01-27 15:59:42.480 EST at RedisClient.on_error (/opt/app/node_modules/redis/index.js:341:14)
Default
2021-01-27 15:59:42.480 EST at Socket.<anonymous> (/opt/app/node_modules/redis/index.js:222:14)
Default
2021-01-27 15:59:42.480 EST at Socket.emit (events.js:315:20)
Default
2021-01-27 15:59:42.480 EST at emitErrorNT (internal/streams/destroy.js:106:8)
Default
2021-01-27 15:59:42.480 EST at emitErrorCloseNT (internal/streams/destroy.js:74:3)
Default
2021-01-27 15:59:42.480 EST at processTicksAndRejections (internal/process/task_queues.js:80:21) {
Default
2021-01-27 15:59:42.480 EST errno: -104,
Default
2021-01-27 15:59:42.480 EST code: 'ECONNRESET',
Default
2021-01-27 15:59:42.480 EST syscall: 'read'
Default
2021-01-27 15:59:42.480 EST}
Warning
2021-01-27 15:59:46.579 ESTContainer called exit(1).
I'm totally aware that something inside GCLOUD network could be wrong or even in the REDIS-SERVER. But why I can't handle this error? it keeps killing my app.
question from:
https://stackoverflow.com/questions/65927553/redis-node-redis-unhandled-error-event 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…