Read ECONNRESET every 3 mins - NodeJS server crashes due to this. Using newrelic plugin for server monitoring.
Error: Redis connection to redis1.tfs.tfs:6379 failed - read ECONNRESET at RedisClient.on_error (/var/www/a/b/c/node_modules/redis/index.js:196:24) at Socket.
To me, this sounds like a networking issue outside Node.js, this error "ECONNRESET" is when the remote connection to Node.js closes the socket unexpectedly.
Are you using a proxy between Node and Redis?
What version of Node/node_redis/Redis server?
I doubt the NewRelic agent is involved, but you could always try to reproduce without the agent and see if that fixes the issue. cc/ @wraithan
Those lines are just CLS doing it's thing. With more of a repro I could fully rule out the New Relic agent. But I'm relatively confident this isn't being caused by us.
I removed the NewRelic agent, the problem still occurs. Approx. every 3 mins I get this crash happening. Below are the logs for reference.
events.js:72
throw er; // Unhandled 'error' event
^
Error: Redis connection to redis1.tfs.tfs:6379 failed - read ECONNRESET
at RedisClient.on_error (/var/www/a/b/c/node_modules/redis/index.js:196:24)
at Socket.
Also, I'm using Node.JS - v0.10.35, node_redis - 0.12.1 & Redis - 2.8.4. I'm accessing Redis directly via IP in Node.
I was facing this problem too, but just got resolved after I realized I was playing around with my /etc/hosts file yesterday for some other reason. It was missing:
127.0.0.1 localhost
@ayazpasha2434 the solution might not be the same for you, but like others are hinting, it is defintely outside node and in the env/shell/OS/VM. Step back a little and stare at it.
@sarathms I have this mapping in my hosts file. However, the Redis machine in my case is a remote one. Just cross-checked, I have the said localhost mapping in Redis machine as well. Still the problem is not solved.
I am also facing the same problem . Here is the Console Output
events.js:72
throw er; // Unhandled 'error' event
^
Error: Redis connection to pub-redis-10606.us-east-1-1.1.ec2.garantiadata.com:10606 failed - read ECONNRESET at RedisClient.on_error (C:\Users\Gigi\Desktop\eduknow_api_ver_1\auth\node_m
odules\redis\index.js:196:24)
at Socket.
@ayazpasha2434 This line solved my error
client.on('error',function(err){ console.error(err)})
@ayazpasha2434 Did @Waterloo have the right answer for you?
There seemed to be an issue with your network connection and it does not seem to be an issue with node redis. Adding the error handler should be sufficient so the app does not crash anymore (and it should always be attached).
I met this problem when I post a http(use post) to JAVA server.{ [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read', response: undefined } Error: read ECONNRESET at exports._errnoException (util.js:856:11) at TCP.onread (net.js:546:26) double callback! POST /user_archives/create/save 500 45.306 ms - 386 Error: read ECONNRESET at exports._errnoException (util.js:856:11) at TCP.onread (net.js:546:26)
@biggu0 I'm not sure what connection this has to node_redis. To find out more about ECONNRESET you might want to look at stackoverflow.
Hi There , We are also seeing this issue. We observe that it could be because of redis SNAPSHOTTING . Whenever redis is taking snapshot and storing on the disk connection is getting reset. To prove myself i compare the application logs with redis debug logs and the timings are matching exactly.
below are the snapshotting setting in redis.conf save 900 1 save 300 10 save 60 10000
Please let us know if we are doing something wrong.
I am also facing connection issue frequently .
ERR at RedisClient.emit (events.js:188:7)
ERR at RedisClient.on_error (/home/vcap/app/node_modules/redis/index.js:394:14)
ERR at RedisClient.
After getting the error it is automatically reconnecting. What can be the issue to lost the connection.
Hi Waterloo , Where you put this statement client.on('error',function(err){ console.error(err)}) and i think this statement just for console your error nothing else. is it really usable? Please give me your thoughts asap.
Thanks in advance!!!
Hello
I am also facing the same issue
events.js:160 throw er; // Unhandled 'error' event ^
Error: read ECONNRESET
This solved my problem with:
- I disabled all of my processes monitoring (new relic, elastic apm ...)
- I used this code
process.on('uncaughtException', function (err) {
console.error(err.stack);
console.log("Node NOT Exiting...");
});
I ma also facing this issue. I am using with sails.js framework with a hook, so there is only one connection to redis server when starting node service, we will use global sails object to access and work with redis
redisClient = redis.createClient({
host: redisConfig.host,
port: redisConfig.port,
db: redisConfig.db,
retry_strategy: (retryOptions) => {
if (retryOptions.error && retryOptions.error.code === 'ECONNREFUSED') {
// End reconnecting on a specific error and flush all commands with
// a individual error
return new Error('The server refused the connection');
}
if (retryOptions.total_retry_time > 1000 * 60 * 60) {
// End reconnecting after a specific timeout and flush all commands
// with a individual error
return new Error('Retry time exhausted');
}
if (retryOptions.attempt > 3) {
// End reconnecting with built in error
return undefined;
}
sails.log.debug('Handling redis retry strategy', {
error: retryOptions.error,
totalRetryTime: retryOptions.total_retry_time,
attempt: retryOptions.attempt
});
// Reconnect after
return Math.min(retryOptions.attempt * 100, 3000);
}
});
Here is the stack trace of the error
AbortError: Redis connection lost and command aborted. It might have been processed.\n at RedisClient.flush_and_error (/var/sample-app/node_modules/redis/index.js:362:23)\n at RedisClient.connection_gone (/var/sample-app/node_modules/redis/index.js:664:14)\n at RedisClient.on_error (/var/sample-app/node_modules/redis/index.js:410:10)\n at Socket.
Our node app is running on a Docker container and it will connect to Redis server installed on an EC2 linux instance.
We also facing same issue, but here we placed the stunnel to proxy the redis to localhost using below stunnel configuration.
fips = no #setuid = root #setgid = root pid = /var/run/stunnel.pid debug = 7 #options = NO_SSLv2 options = NO_SSLv3 output = /var/log/stunnel.log #client = no #foreground = yes
[redis-cli] client = yes accept = 127.0.0.1:6379 connect = redisendpoint:6379
node is disconnecting with these below errors for every couple of minutes. We running these through docker containers.
Redis connection to 127.0.0.1:6379 failed - read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:111:27) Error: Redis connection to 127.0.0.1:6379 failed - read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:111:27) Error: Redis connection to 127.0.0.1:6379 failed - read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:111:27) AbortError: Redis connection lost and command aborted. It might have been processed.
any resolution ?
We also facing same issue, but here we placed the stunnel to proxy the redis to localhost using below stunnel configuration.
fips = no #setuid = root #setgid = root pid = /var/run/stunnel.pid debug = 7 #options = NO_SSLv2 options = NO_SSLv3 output = /var/log/stunnel.log #client = no #foreground = yes
[redis-cli] client = yes accept = 127.0.0.1:6379 connect = redisendpoint:6379
node is disconnecting with these below errors for every couple of minutes. We running these through docker containers.
Redis connection to 127.0.0.1:6379 failed - read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:111:27) Error: Redis connection to 127.0.0.1:6379 failed - read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:111:27) Error: Redis connection to 127.0.0.1:6379 failed - read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:111:27) AbortError: Redis connection lost and command aborted. It might have been processed.
any resolution ?
same to me i think this is an issue with stunnel
I am also facing same error
{ Error: Redis connection to xx.xx.x.x:6379 failed - read ECONNRESET"
at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read'
I am also using error handler but the thing is why is this happening, it can impact my query calls and delay my requests.
@Ayaz Can you please open this issue because this issue is not completely resolved people only have handled error response but the problem is still unresolved.