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

Add DisableHelloCmd options #2792

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ type Options struct {
// Disable set-lib on connect. Default is false.
DisableIndentity bool

// Disable Hello on connect. Default is false.
// Hello is used to check the server version,but in Enterprise environment with twproxy,it will cause error,return EOF panic.
DisableHelloCmd bool

// Add suffix to client name. Default is empty.
IdentitySuffix string

}

func (opt *Options) init() {
Expand Down
28 changes: 15 additions & 13 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,21 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
protocol = 3
}

// for redis-server versions that do not support the HELLO command,
// RESP2 will continue to be used.
if err := conn.Hello(ctx, protocol, username, password, "").Err(); err == nil {
auth = true
} else if !isRedisError(err) {
// When the server responds with the RESP protocol and the result is not a normal
// execution result of the HELLO command, we consider it to be an indication that
// the server does not support the HELLO command.
// The server may be a redis-server that does not support the HELLO command,
// or it could be DragonflyDB or a third-party redis-proxy. They all respond
// with different error string results for unsupported commands, making it
// difficult to rely on error strings to determine all results.
return err
if !c.opt.DisableHelloCmd {
// for redis-server versions that do not support the HELLO command,
// RESP2 will continue to be used.
if err := conn.Hello(ctx, protocol, username, password, "").Err(); err == nil {
auth = true
} else if !isRedisError(err) {
// When the server responds with the RESP protocol and the result is not a normal
// execution result of the HELLO command, we consider it to be an indication that
// the server does not support the HELLO command.
// The server may be a redis-server that does not support the HELLO command,
// or it could be DragonflyDB or a third-party redis-proxy. They all respond
// with different error string results for unsupported commands, making it
// difficult to rely on error strings to determine all results.
return err
}
}

_, err := conn.Pipelined(ctx, func(pipe Pipeliner) error {
Expand Down
Loading