fix: Bitget WS keepalive — send text ping, not WebSocket PingMessage

Bitget v2 WS requires a text message "ping" every 30s, not a WebSocket
PingMessage control frame (opcode 0x9). Using the wrong ping type caused
a silent failure: connection stays up and subscription succeeds, but NO
ticker data is pushed — zero errors, zero reconnection logs.

Changes:
- connector.go: Add TextPing bool flag, send text 'ping' when set
- bitget.go: Set TextPing=true, handle text 'pong', add debug logging
- scanner.go: Expand to 179 overlapping Bitget+HL coins
This commit is contained in:
jackyu66git
2026-05-04 00:33:03 +08:00
parent e04a165d69
commit 2ed6ffc747
5 changed files with 45246 additions and 22 deletions
+13 -2
View File
@@ -16,6 +16,10 @@ type PriceConnector struct {
ReconnectBase time.Duration
PingInterval time.Duration // 0 = no client-side pings
// TextPing: if true, sends text message "ping" instead of WebSocket PingMessage frame.
// Used by Bitget v2 WS which expects a JSON/text "ping" string.
TextPing bool
OnConnect func()
OnMessage func([]byte)
OnError func(error)
@@ -91,8 +95,15 @@ func (pc *PriceConnector) Run() error {
for {
select {
case <-ticker.C:
if err := c.WriteMessage(websocket.PingMessage, nil); err != nil {
return
if pc.TextPing {
// Bitget v2 expects a TEXT message "ping", not WebSocket PingMessage frame
if err := c.WriteMessage(websocket.TextMessage, []byte("ping")); err != nil {
return
}
} else {
if err := c.WriteMessage(websocket.PingMessage, nil); err != nil {
return
}
}
case <-pingStop:
return