-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled error event: Error: read ECONNRESET at TCP.onStreamRead #1203
Comments
I am also having this issue |
Me too. I'll watch this issue. |
Got the same problem |
same issue, tried reseting the worker, deleting and recreating the redis instance but no luck |
Turns out Heroku's Redis v6 instances are self-signing certificates. Passing |
Hey, I have the same. Seems like following PR might resolve that: #1236. |
Sorry for the late response. This issue should be fixed in the latest version published in the last week. Closing this. Feel free to reopen if there are any issues. |
Im still getting the problem and im on the latest version. |
Getting the problem too |
I am getting this too |
Any news for this issue, I am having the same problem. |
im getting this too |
Network issues can be the cause of |
i guess,ioredis's
|
I am getting the same error, any workaround for this? |
I resolved my issue by using the following option
Can try if it helps at your side |
hi @dopt do you use AWS elasticCache or self hosted redis instance? |
i dont understand whats the relationship with this attribute. finding the root cause and fixing it is the best solution |
The right way to do this is to handle the error gracefully. The problem seems to be the IORedis client's behaviour of timed disconnect when inactive but it has an auto reconnect mechanism that will keep trying to reconnect. Use Node.js Event Emitter to handle it. View all events with import Redis from 'ioredis';
import dotenv from 'dotenv';
import path from 'path';
dotenv.config({ path: path.resolve(__dirname, '../.env') });
const client = new Redis({
port: Number(process.env.SESSION_STORE_PORT) || 6379,
host: process.env.SESSION_STORE_HOSTNAME,
});
// Listen to 'error' events to the Redis connection
client.on('error', error => {
if (error.code === 'ECONNRESET') {
console.log('Connection to Redis Session Store timed out.');
} else if (error.code === 'ECONNREFUSED') {
console.log('Connection to Redis Session Store refused!');
} else console.log(error);
});
// Listen to 'reconnecting' event to Redis
client.on('reconnecting', err => {
if (client.status === 'reconnecting')
console.log('Reconnecting to Redis Session Store...');
else console.log('Error reconnecting to Redis Session Store.');
});
// Listen to the 'connect' event to Redis
client.on('connect', err => {
if (!err) console.log('Connected to Redis Session Store!');
});
export default client; References: |
Hello, you don't instance radis, when your application starts. you'll instance when you use the radis. Exemple here: try {
await redis.set("test", "test")
} catch (err) {
console.log("error", err)
} finally {
redis.quit() // stop connection here, and init other when you need
} |
This is okay only when your application is having low throughput into redis. For a medium to higher throughput application, why would you want to open and close connection for every R/W operation and increase your latency per operation? In most cases, you want to keep it open and gracefully handle the error then, unless there's a security reason why you should not or if it's infrequent use. |
There is still this error in 2024... |
same issue, tried reseting the worker, deleting and recreating the redis instance but no luck |
@babeingineer try this |
In my case : it is not working : in development mode (http) so using this helped, but in production : remove this |
None of the solutions is working for me |
me too. |
Hi,
I am getting below error sometimes. Redis connection gets disconnected sometime. Out of 10 I am facing this issue 2 time. It takes time to reconnect the server and api response time increases from 50-80 msec to 1-2 mins.
Error : Unhandled error event: Error: read ECONNRESET at TCP.onStreamRead
Ioredis client configuration as below:
var redisMasterClient = new IORedis({
host: host ,
connectTimeout: 1000,
password: "password,
keepAlive : 1000,
retryStrategy: function(times) {
var delay = Math.min(times * 10, 2000);
return delay;
},
maxRetriesPerRequest: 1
});
Please help. This is urgent issue on production.
The text was updated successfully, but these errors were encountered: