Skip to content

Commit

Permalink
feat: 修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
godLei6 committed Nov 30, 2023
1 parent 8887e9d commit cf89a10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion taosWS/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion taosWS/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit cf89a10

Please sign in to comment.