redis createclient giving error "SocketClosedUnexpectedlyError" while connecting to elasticache redis

0

I have below code setup which is resulting in pubClient getting connected successfully and then giving error message: pubClient SocketClosedUnexpectedlyError: Socket closed unexpectedly at Socket.<anonymous> (/var/app/current/node_modules/@redis/client/dist/lib/client/socket.js:194:118) at Object.onceWrapper (node:events:629:26) at Socket.emit (node:events:514:28) at TCP.<anonymous> (node:net:337:12).

my code is as below: let pubClient, subClient; try { pubClient = createClient({ socket: { host: '<elasticache-redis-endpoint>', port: <port number> } }); subClient = pubClient.duplicate();

} catch (error) { console.error('Failed to create Redis clients:', error); }

Promise.all([pubClient.connect(), subClient.connect()]).then(() => { io.adapter(createAdapter(pubClient, subClient)); io.listen(5003); });

  • Hi, Its seems that you successfully create the client, but its fail to connect. Your code is failing on /var/app/current/node_modules/@redis/client/dist/lib/client/socket.js:194:118 which is part of the socket connection. Its hard to say from the info shared what could be the problem, can you please share a bit more info? maybe try to add error logging to the connection. Please check that your configuration are right, as access from your app to your Elasticache.

已提問 1 個月前檢視次數 103 次
1 個回答
0

Hello!

Errors with Elasticache Redis during the connection establishment process such as SocketClosedUnexpectedlyError are typically due to some sort of configuration issue occurring when attempting to connect to the cluster. This includes situations such as:

I would first recommend making sure you can establish a connection to the cluster from the instance/machine that your application/client is running in (see this guide for instructions on how to perform this https://repost.aws/knowledge-center/elasticache-connection-test).

Should you require further assistance with this, please create an AWS support case with additional details such as the cluster ID and timestamp (in UTC format) of when the connection attempt was made to get in touch with an available engineer.

https://docs.aws.amazon.com/awssupport/latest/user/case-management.html

AWS
支援工程師
Juan_P
已回答 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南