Skip to content

Lettuce not sending keepAlives #3177

Closed Answered by tishun
sklakegg asked this question in Q&A
Feb 11, 2025 · 2 comments · 8 replies
Discussion options

You must be logged in to vote

In this case my recommended approach would be to implement a NettyCustomizer (see #499) that add a custom IdleStateHandler that sends PING commands when the channel is inactive.

My idea was a bit simpler and should work with any type of connection made with a client that has the appropriate ClientResources configured.

You need 3 parts.

First you configure the client to use a Netty customizer of your own:

        StatefulRedisConnection<String, String> connection;
        ClientResources resources = ClientResources.builder().nettyCustomizer(new HeartBeatCustomizer()).build();

        try (RedisClient redisClient = RedisClient.create(resources, RedisURI.create("com.acme", 6474))) {
     …

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@tishun
Comment options

@sklakegg
Comment options

@tishun
Comment options

@tishun
Comment options

Answer selected by sklakegg
@tishun
Comment options

@sklakegg
Comment options

@tishun
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants