From cf89a10bc10d149d27b32933ef0800bb3a3b8cb8 Mon Sep 17 00:00:00 2001 From: godLei6 <603785348@qq.com> Date: Thu, 30 Nov 2023 19:16:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taosWS/connection.go | 4 +++- taosWS/connector.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/taosWS/connection.go b/taosWS/connection.go index 9611a11..ac2e436 100644 --- a/taosWS/connection.go +++ b/taosWS/connection.go @@ -59,7 +59,7 @@ func (tc *taosConn) generateReqID() uint64 { return atomic.AddUint64(&tc.requestID, 1) } -func newTaosConn(cfg *config) (*taosConn, error) { +func newTaosConn(ctx context.Context, cfg *config) (*taosConn, error) { endpointUrl := &url.URL{ Scheme: cfg.net, Host: fmt.Sprintf("%s:%d", cfg.addr, cfg.port), @@ -91,7 +91,9 @@ func newTaosConn(cfg *config) (*taosConn, error) { err = tc.connect() if err != nil { + logx.WithContext(ctx).Errorf("websocket 连接失败,err:%v", err) tc.Close() + return nil, err } return tc, nil } diff --git a/taosWS/connector.go b/taosWS/connector.go index 8259d09..9310ee9 100644 --- a/taosWS/connector.go +++ b/taosWS/connector.go @@ -36,7 +36,7 @@ func (c *connector) Connect(ctx context.Context) (driver.Conn, error) { if c.cfg.writeTimeout == 0 { c.cfg.writeTimeout = common.DefaultWriteWait } - tc, err := newTaosConn(c.cfg) + tc, err := newTaosConn(ctx, c.cfg) return tc, err }