Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection reconnect suspended after reconnect to Redis with protected mode #2770

Closed
ZH379411584 opened this issue Feb 28, 2024 · 1 comment
Labels
type: bug A general bug
Milestone

Comments

@ZH379411584
Copy link

Bug Report

time action or behave
T1 lettuce connect redis normal
T2 use deafult redis config restart redis
T3 lettuce throw protected-mode yes error
T4 use correct redis config restart redis
T5 lettuce still throw protected-mode yes error

lettuce give up reconntect after redis-server reply ‘DENIED Redis is running in protected mode ...’

error stack

Caused by: io.lettuce.core.RedisException: io.lettuce.core.RedisConnectionException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
        at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:129)
        at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:69)
        at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
        at com.sun.proxy.$Proxy127.hvals(Unknown Source)
        at org.springframework.data.redis.connection.lettuce.LettuceHashCommands.hVals(LettuceHashCommands.java:369)
        ... 79 common frames omitted
Caused by: io.lettuce.core.RedisConnectionException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
        at io.lettuce.core.protocol.CommandHandler.onProtectedMode(CommandHandler.java:751)
        at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:597)
        at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:556)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1421)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:794)
        at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollRdHupReady(AbstractEpollChannel.java:437)
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:431)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:326)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        ... 1 common frames omitted

Expected behavior/code

read the source code, the reason of disabled reconnect when receive protected-mode yes is use in first connect.

Environment

  • Lettuce version(s): [5.1.2.RELEASE]
  • Redis version: [3.2.12]

Possible Solution

because many application use redis, I have to restart all of application .

Additional context

@mp911de
Copy link
Collaborator

mp911de commented Feb 28, 2024

In #608 we disabled reconnect for protected mode failures. It should be possible to disambiguate between initial connect and reconnect failures.

@mp911de mp911de changed the title still throw protected-mode yes error after redis set protected-mode no Connection reconnect suspended after reconnect to Redis with protected mode Feb 28, 2024
@mp911de mp911de added the type: bug A general bug label Feb 28, 2024
mp911de added a commit that referenced this issue Mar 5, 2024
We now no longer suspend auto-reconnect when a connection encounters protected mode.
mp911de added a commit that referenced this issue Mar 5, 2024
We now no longer suspend auto-reconnect when a connection encounters protected mode.
@mp911de mp911de added this to the 6.3.2.RELEASE milestone Mar 5, 2024
@mp911de mp911de closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants