fix: can not open connection when "CLIENT" command killed #78

This commit is contained in:
Lykin 2023-11-21 18:13:26 +08:00
parent 9aaf32e2bf
commit 30d6da85a1
2 changed files with 2 additions and 3 deletions

View File

@ -251,6 +251,8 @@ func (b *browserService) getRedisClient(connName string, db int) (item connectio
err = fmt.Errorf("create conenction error: %s", err.Error())
return
}
_ = client.Do(b.ctx, "CLIENT", "SETNAME", url.QueryEscape(selConn.Name)).Err()
// add hook to each node in cluster mode
var cluster *redis.ClusterClient
if cluster, ok = client.(*redis.ClusterClient); ok {

View File

@ -9,7 +9,6 @@ import (
"github.com/redis/go-redis/v9"
"golang.org/x/crypto/ssh"
"net"
"net/url"
"os"
"strings"
"sync"
@ -120,7 +119,6 @@ func (c *connectionService) buildOption(config types.ConnectionConfig) (*redis.O
}
option := &redis.Options{
ClientName: url.QueryEscape(config.Name),
Addr: fmt.Sprintf("%s:%d", config.Addr, config.Port),
Username: config.Username,
Password: config.Password,
@ -174,7 +172,6 @@ func (c *connectionService) createRedisClient(config types.ConnectionConfig) (re
//RouteByLatency: false,
//RouteRandomly: false,
//ClusterSlots: nil,
ClientName: url.QueryEscape(option.ClientName),
Dialer: option.Dialer,
OnConnect: option.OnConnect,
Protocol: option.Protocol,