Connection Timed Out Error

1,259 views
Skip to first unread message

parvathy sasikala

unread,
Apr 26, 2019, 3:12:31 AM4/26/19
to lettuce-redis-client-users
Hi,
I am getting a connection timed error while using my lettuce client. But i am able to execute the same query from console, looks like a connection pooling issue for me,
please find below, the code which I use for creating the pool and getting the connection. Please let me know what I am doing wrong with it. In my application, there are a lot of redis queries from different threads, happening simultaneously.
Client and connection pool creation :
 redisClient = RedisClusterClient.create(redisNodes);
            ClusterTopologyRefreshOptions topologyRefreshOptions = ClusterTopologyRefreshOptions.builder()
                    .enableAdaptiveRefreshTrigger(RefreshTrigger.MOVED_REDIRECT, RefreshTrigger.PERSISTENT_RECONNECTS)
                    .build();
            
            redisClient.setOptions(ClusterClientOptions.builder().topologyRefreshOptions(topologyRefreshOptions).build());
            connPool= ConnectionPoolSupport
                    .createGenericObjectPool(() -> redisClient.connect(),
                            new GenericObjectPoolConfig<StatefulRedisClusterConnection<String, String>>());

Example Operation code:
   try (StatefulRedisClusterConnection<String, String> connection = connPool.borrowObject()) {
            Long exists = connection.sync().exists(namespace);
            if (exists != null && exists > 0)
                return true;
        } catch (Exception e) {
         
        }
        return false;

Please help.

Thanks,
Parvathy 

Mark Paluch

unread,
Apr 26, 2019, 3:26:05 AM4/26/19
to lettuce-redis-client-users
Please provide us with a bit or error details such as a stack trace. 

Cheers,
Mark
--
You received this message because you are subscribed to the Google Groups "lettuce-redis-client-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lettuce-redis-clien...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lettuce-redis-client-users/466c6de1-c3d3-4e3d-88e0-06466facd2bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Parvathy S

unread,
Apr 26, 2019, 3:34:13 AM4/26/19
to Mark Paluch, lettuce-redis-client-users
Hi Mark,
Thanks a lot for such a quick reply. Please find the details below.
io.lettuce.core.RedisCommandTimeoutException: Command timed out after 1 minute(s)
at io.lettuce.core.ExceptionFactory.createTimeoutException(ExceptionFactory.java:51)
at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:114)
at io.lettuce.core.cluster.ClusterFutureSyncInvocationHandler.handleInvocation(ClusterFutureSyncInvocationHandler.java:123)
at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
at com.sun.proxy.$Proxy17.hget(Unknown Source)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.lettuce.core.support.ConnectionWrapping$DelegateCloseToConnectionInvocationHandler.handleInvocation(ConnectionWrapping.java:190)
at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
at com.sun.proxy.$Proxy17.hget(Unknown Source)

Thanks,
Parvathy 

Mark Paluch

unread,
Apr 26, 2019, 7:16:39 AM4/26/19
to lettuce-redis...@googlegroups.com
Hi Parvathy,

Command timeouts aren’t usual. However, a timeout of one minute happens typically either when your connection got disconnected/interrupted or when the connection was blocked by e.g. blocking commands.

You can enable debug logging to retrieve log details about when commands were sent and when those were received. 

Cheers, 
Mark

parvathy sasikala

unread,
Apr 27, 2019, 11:33:29 PM4/27/19
to lettuce-redis-client-users
Hi Mark,
We were using commands.setAutoFlushCommands(false); in one of the places to do a pipe lining,looks like that was causing the problem. It is not happening, after we removed the setting.

Thanks for the help. 

Thanks,
Parvathy 
Reply all
Reply to author
Forward
0 new messages