RedisCommandTimeoutException when there is a network glitch
See original GitHub issueHi,
We have a daemon process which pushes data to redis on AWS using lettuce-core. I have noticed that during network glitch i.e when a connection is disconnected , I get below exception :
io.lettuce.core.RedisCommandTimeoutException: Command timed out
at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:114)
at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:62)
at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
at com.sun.proxy.$Proxy11.hmget(Unknown Source)
Code to reproduce :
public class TestMain {
public static void main(String[] args) {
Duration timeout = Duration.ofMillis(10000);
RedisClient client = RedisClient.create(RedisURI.create("redis://127.0.0.1:6379"));
client.setDefaultTimeout(timeout);
RedisCommands<String, String> commands = client.connect().sync();
String[] arr = { "test", "test2" };
int i = 1;
while (i <= 1000) {
try {
List<KeyValue<String, String>> op = commands.hmget("TEST", arr);
System.out.println(op);
i++;
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Version :
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>5.0.3.RELEASE</version>
</dependency>
After the connection is re-established it works fine. The time out given is around 10 seconds and network connection is fixed before 10 seconds but still this exception occur. Ideally it should have waited for 10 seconds before throwing the exception.
Also the exception thrown seems to be incorrect i.e RedisCommandTimeoutException
, could have been something different.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Command timed out after 1 minute(s) during load test
On reading about this (redis command timeout ) exception, we understand that this occurs due to connection issue (channel getting disconnected) or the...
Read more >io.lettuce.core.RedisCommandTimeoutException: Command ...
Spring Boot provide it out of the box with almost no codding, Its just a matter of configuring your application.yml.
Read more >Troubleshoot Azure Cache for Redis latency and timeouts
Learn how to resolve common latency and timeout issues with Azure Cache for Redis, such as Redis server patching and timeout exceptions.
Read more >Troubleshooting - Amazon ElastiCache for Redis
Network ACLs are assigned to subnets, not specific resources. It is possible to have the same ACL assigned to ElastiCache and the client...
Read more >lettuce-io/Lobby - Gitter
Unexpected error occurred in scheduled task. ... We have a ticket (lettuce-io/lettuce-core#795) but there was not sufficient interest from any side to come ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this params would mend it: echo “1” > /proc/sys/net/ipv4/tcp_keepalive_intvl echo “10” > /proc/sys/net/ipv4/tcp_keepalive_probes echo “6” > /proc/sys/net/ipv4/tcp_keepalive_time echo “3” > /proc/sys/net/ipv4/tcp_retries2
mp911de is right but it may worth have a look to cassandra or elasticsearch drivers which are able to recover from these problem
diving a bit I found nettycustommizer, this works too: