1 Answer
- Newest
- Most votes
- Most comments
1
Hello
Greetings for the day!
Based on the provided information and error, The error 'io.lettuce.core.RedisConnectionException: Connection closed prematurely' can be commonly caused by issues with TLS. Since Lettuce is a third party client and as mentioned you have already enabled TLS for this cluster, I don't have expertise to comment on specific client configurations. However for a reference, you can use this sample code from our documentation for the Lettuce client to compare:
Along with the previously shared documentation from AWS, this third party discussion board reports very similar error messages such as "Connection closed prematurely". The key configuration needed in the code seems to be the ".withSsl(true)" argument.
answered 7 months ago
Relevant content
- asked 4 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 7 months ago
Thanks Himanshu - yes I discovered that this issue was caused by my use of the withStartTls() method
Since the AWS docs clearly state that clients must connect over TLS, I figured the following Lettuce client configuration was necessary (specifically when building the RedisURI):
Turns out withStartTls() must be called/set with the value FALSE in order to connect to an ElastiCache Serverless cluster
That was not intuitive to me, based on the name of that method and the javadoc associated with it And now, that Google group discussion you referenced helps to confirm that fact (even though it was not regarding a Serverless cluster).
So, in case this helps anyone else, the final bits of configuration I had to use to connect to EC Serverless using the Lettuce Redis client library was:
hth