test: 补齐短时间可测验收并修复建群下行卡住

This commit is contained in:
Nixevol
2026-09-30 10:20:47 +08:00
parent 4e3c84366f
commit 479a08ee11
12 changed files with 1078 additions and 87 deletions
+3 -1
View File
@@ -34,7 +34,7 @@ func DialMQTTTCP(addr string, timeout time.Duration) (MQTTClient, error) {
if err != nil {
return nil, err
}
_ = conn.SetDeadline(time.Now().Add(timeout))
_ = conn.SetDeadline(time.Time{})
return &tcpMQTT{conn: conn, r: bufio.NewReader(conn)}, nil
}
@@ -126,6 +126,8 @@ func DialMQTTWebSocket(httpBase string, timeout time.Duration) (MQTTClient, erro
_ = raw.Close()
return nil, fmt.Errorf("unexpected subprotocol %q", proto)
}
// 握手完成后清掉超时,否则长会话后续读写会在 dial timeout 到期后全部失败。
_ = raw.SetDeadline(time.Time{})
return &wsMQTT{conn: raw, r: br}, nil
}