Socket closed unexpectedly

See original GitHub issue

Hi mates, Redis often throw error like above Socket closed unexpectedly, could we turn socket connection off from redis? Thanks, Thu

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:37

github_iconTop GitHub Comments

4reactions
h2mediacommented, May 16, 2022

@leibale i have a same problem, i was update node-redis to 4.1.0

`var redis = require(“redis”); const fs = require(‘fs’);

const redisClient = redis.createClient({ url: rediss://api3-redis-master.api3-pro.svc.cluster.local:6379, socket: { tls: true, rejectUnauthorized: false, ca: fs.readFileSync(‘ks8-ca-cert.crt’, encoding=‘ascii’), servername: “api3-redis-master.api3-pro.svc.cluster.local” }, legacyMode: true });

redisClient.on(‘error’, function(err){ console.log(‘Redis Client Error’, err); }); redisClient.on(‘connect’, () => { console.log(Redis connected); });

(async () => { // Connect to redis server await redisClient.connect(); redisClient.get(‘test_tls’, function(err, result){ console.log(err, result); }); })();`

After 30 minutes when starting nodejs start, redis gives error and reconnects itself

SocketClosedUnexpectedlyError: Socket closed unexpectedly at TLSSocket.<anonymous> (/data/www/public_html/cloud_api3/node_modules/@redis/client/dist/lib/client/socket.js:156:118) at Object.onceWrapper (node:events:646:26) at TLSSocket.emit (node:events:538:35) at node:net:687:12 at TCP.done (node:_tls_wrap:580:7)

3reactions
tuanpt-0634commented, May 19, 2022

You should check for client timeout in redis server config => https://redis.io/docs/reference/clients/#client-timeouts

Read more comments on GitHub >

github_iconTop Results From Across the Web

Socket closed unexpectedly · Issue #2032 · redis ... - GitHub
I tried to comment out next code and it doesn't close the connection at all (from @socket.io/redis-adapter). this.subClient.pSubscribe(this.
Read more >
Reusing Redis Connection: Socket Closed Unexpectedly ...
I solved this using the 'error' listener. Just listening to it - saves the node application from crashing.
Read more >
Error "Socket closed unexpectedly" will happen for each 10 ...
My app is using Azure Cache for Redis(Basic plan). But I found Error "Socket closed unexpectedly" will happen for each 10 mins after...
Read more >
[SOLVED] Error: Socket closed unexpectedly - Redis Node.js
Error: Socket closed unexpectedly. That caused my application to crash and restart multiple times because of the unhandled error.
Read more >
Redis SocketClosedUnexpectedlyError: Socket closed ... - Fly.io
Hello. On fly.io it seems that redis is disconnected consistently (every 1 minute) SocketClosedUnexpectedlyError: Socket closed unexpectedly ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found