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.

질문됨 한 달 전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
답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인