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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则