spring-boot-starter-data-redis 2.7.3 getting Connection refused occasionally with LettuceConnectionFactory

Viewed 54

When using the following LettuceConnectionFactory configuration

    @Bean
    @Primary
    public ReactiveRedisConnectionFactory connectionFactory(@Value("${spring.redis.host}") String host,
                                                            @Value("${spring.redis.port}") int port) {
        return new LettuceConnectionFactory(host, port);
    }

I frequently get

java.net.ConnectException: finishConnect(..) failed: Connection refused

errors.

Full stack trace:

    io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: [HOST]/10.16.66.12:6379
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
    at io.netty.channel.unix.Errors.newConnectException0(Errors.java:155) ~[netty-transport-native-unix-common-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128) ~[netty-transport-native-unix-common-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.channel.unix.Socket.finishConnect(Socket.java:320) ~[netty-transport-native-unix-common-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:710) ~[netty-transport-classes-epoll-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:687) ~[netty-transport-classes-epoll-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:567) ~[netty-transport-classes-epoll-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:470) ~[netty-transport-classes-epoll-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) ~[netty-transport-classes-epoll-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-common-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.75.Final.jar!/:4.1.75.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.75.Final.jar!/:4.1.75.Final]
    at java.lang.Thread.run(Unknown Source) ~[?:?]

Before that there are a lot of reconnect attempts

[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 1, delay 1ms
[channel=0x43ff8ced, /172.16.0.213:37908 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 2, delay 2ms
[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 3, delay 4ms
[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 4, delay 8ms
[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 5, delay 16ms
[channel=0x43ff8ced, /172.16.0.213:37908 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 6, delay 32ms
[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 7, delay 64ms
[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 8, delay 128ms
[channel=0x43ff8ced, /172.16.0.213:37908 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 9, delay 256ms      
[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 10, delay 512ms
[channel=0x43ff8ced, /172.16.0.213:37908 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 11, delay 1024ms
[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 12, delay 2048ms
[channel=0x43ff8ced, /172.16.0.213:37908 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 13, delay 4096ms
[channel=0xe9b4a42f, /172.16.0.213:37882 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 14, delay 8192ms
[channel=0x43ff8ced, /172.16.0.213:37908 -> [HOST]/10.16.66.12:6379, last known addr=[HOST]/10.16.66.12:6379] Reconnect attempt 15, delay 16384ms


What is this channel channel=0xc8069021, /172.16.2.223:36912 and why does it change it's IP between reconnect attempts?

0 Answers
Related