mirror of https://github.com/go-redis/redis.git
Merge pull request #2119 from szyhf/szyhf-patch-1
fix: #2114 for redis-server not support Hello
This commit is contained in:
commit
25db55cdc0
5
redis.go
5
redis.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -228,11 +229,11 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
|
||||||
|
|
||||||
var auth bool
|
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.
|
// we continue to provide services with RESP2.
|
||||||
if err := conn.Hello(ctx, 3, username, password, "").Err(); err == nil {
|
if err := conn.Hello(ctx, 3, username, password, "").Err(); err == nil {
|
||||||
auth = true
|
auth = true
|
||||||
} else if err.Error() != "ERR unknown command 'hello'" {
|
} else if !strings.HasPrefix(err.Error(), "ERR unknown command") {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue