From cdeb2c3aad6d4224f75c632a7898402d144598c9 Mon Sep 17 00:00:00 2001 From: PandaX <18610165312@163.com> Date: Fri, 1 Mar 2024 11:18:33 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8Dtcp=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=96=AD=E5=BC=80=EF=BC=8C=E4=BA=91=E7=AB=AF=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E8=BF=98=E6=98=AFtrue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 1 - go.sum | 2 -- iothub/client/mqttclient/rpc.go | 2 +- iothub/server/tcpserver/hook.go | 3 ++- kit/starter/redis.go | 24 ------------------------ 5 files changed, 3 insertions(+), 29 deletions(-) delete mode 100644 kit/starter/redis.go diff --git a/go.mod b/go.mod index 3924900..3e31dda 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/gin-gonic/gin v1.7.4 github.com/go-openapi/spec v0.20.6 github.com/go-playground/validator/v10 v10.8.0 - github.com/go-redis/redis v6.15.9+incompatible github.com/go-redis/redis/v8 v8.11.5 github.com/golang-queue/queue v0.2.0 github.com/google/uuid v1.3.0 diff --git a/go.sum b/go.sum index d44376f..026833f 100644 --- a/go.sum +++ b/go.sum @@ -122,8 +122,6 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-playground/validator/v10 v10.8.0 h1:1kAa0fCrnpv+QYdkdcRzrRM7AyYs5o8+jZdJCz9xj6k= github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk= -github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg= -github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= diff --git a/iothub/client/mqttclient/rpc.go b/iothub/client/mqttclient/rpc.go index 8fd6604..000a8f3 100644 --- a/iothub/client/mqttclient/rpc.go +++ b/iothub/client/mqttclient/rpc.go @@ -28,7 +28,7 @@ func (rpc RpcRequest) RequestCmd(deviceId, rpcPayload string) error { topic := fmt.Sprintf(RpcReqTopic, rpc.RequestId) value, ok := Session.Load(deviceId) if !ok { - return errors.New("为获取到设备的MQTT连接") + return errors.New("未获取到设备的MQTT连接") } return Publish(topic, value.(string), rpcPayload) } diff --git a/iothub/server/tcpserver/hook.go b/iothub/server/tcpserver/hook.go index a80960d..4abced9 100644 --- a/iothub/server/tcpserver/hook.go +++ b/iothub/server/tcpserver/hook.go @@ -57,6 +57,7 @@ func handleConnection(conn *net.TCPConn, hs *hook_message_work.HookService) { buf := make([]byte, 128) n, err := conn.Read(buf) if err != nil { + isAuth = false return } @@ -125,4 +126,4 @@ func (hhs *HookTcpService) SendBytes(msg []byte) error { func isHex(str string) bool { _, err := hex.DecodeString(str) return err == nil -} \ No newline at end of file +} diff --git a/kit/starter/redis.go b/kit/starter/redis.go deleted file mode 100644 index 9a7c224..0000000 --- a/kit/starter/redis.go +++ /dev/null @@ -1,24 +0,0 @@ -package starter - -import ( - "fmt" - "pandax/kit/logger" - - "github.com/go-redis/redis" -) - -func ConnRedis(host, password string, db, port int) *redis.Client { - // 设置redis客户端 - logger.Log.Infof("连接redis [%s:%d]", host, port) - rdb := redis.NewClient(&redis.Options{ - Addr: fmt.Sprintf("%s:%d", host, port), - Password: password, // no password set - DB: db, // use default DB - }) - // 测试连接 - _, e := rdb.Ping().Result() - if e != nil { - logger.Log.Panic(fmt.Sprintf("连接redis失败! [%s:%d]", host, port)) - } - return rdb -}