Skip to content

Commit

Permalink
fix: #2114 for redis-server not support Hello
Browse files Browse the repository at this point in the history
Using `strings.HasPrefix` instead of `equal`
  • Loading branch information
szyhf authored Jun 10, 2022
1 parent 4ddd7d1 commit b6d2a92
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"sync/atomic"
"time"

Expand Down Expand Up @@ -228,11 +229,11 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {

var auth bool

// For redis-server <6.0 that does not support the Hello command,
// For redis-server < 6.0 that does not support the Hello command,
// we continue to provide services with RESP2.
if err := conn.Hello(ctx, 3, username, password, "").Err(); err == nil {
auth = true
} else if err.Error() != "ERR unknown command 'hello'" {
} else if !strings.HasPrefix(err.Error(), "ERR unknown command") {
return err
}

Expand Down

0 comments on commit b6d2a92

Please sign in to comment.