Parameter | Type | Required | Description |
---|---|---|---|
app_id | string | Yes | User ID |
app_secret | string | Yes | User secret key |
sport_id | string | No | sport_id, multiple values separated by English commas |
Field | Content |
---|---|
channel | Push type |
push_type | Push type (new addition: new; change: update) |
data | Push content |
push_time_millis | Push time, millisecond timestamp |
Product | Push Link | Channel |
---|---|---|
Sports Scores | Basic Data: /sport/ws/v3/base | League-league, Tournament-series, Stage-stage, Team-team, Player-player |
Sports Scores | Real-time Data: /sport/ws/v3/live | Match-match, Live-live, Result-result, Text Live-tlive, Trend-trend |
Sports Scores | Enhanced Real-time Data: /sport/ws/v3/liveplus | Event-event, Lineup-lineup, Match Statistics-stats |
Sports Scores | Odds Data Push: /sport/ws/v3/rate | Odds-odds |
Sports Scores | Match Mapping Push: /sport/ws/v3/mapping | Match Mapping-mapping |
Esports Scores | Basic Data: /esport/ws/v3/base | League-league, Tournament-series, Stage-stage, Team-team, Player-player, Hero-role, Equipment-equipment |
Esports Scores | Real-time Data: /esport/ws/v3/live | Match-match, Live-live, Result-result, Trend-trend, Event-event |
Esports Scores | Enhanced Real-time Data: /esport/ws/v3/livepro | Real-time Pro-prolive |
Esports Scores | Match Mapping Push: /esport/ws/v3/mapping | Match Mapping-mapping |
Animated Video | Video Live Push: /stream/ws/v3/link | Regular-stream, Pro Live-prostream |
Media Data | Barrage Data Push: /media/ws/v3/chat | Barrage Data-chat |
WebSocket Heartbeat Mechanism Description | ||
Overview | ||
This service uses the WebSocket standard Ping/Pong heartbeat mechanism to maintain an active connection. | ||
Heartbeat Parameters |
Ping Interval: 54 seconds
Heartbeat Type: Standard WebSocket Ping/Pong frames (RFC 6455 Section 5.5.2)
Client Requirements
Automatic Handling (Recommended)
Most WebSocket client libraries have built-in Ping/Pong automatic handling mechanisms:
Automatically reply with a Pong frame upon receiving a Ping frame
No additional code implementation required
Manual Implementation
If the client library you are using does not support automatic Pong responses, you need to implement it manually:
Listen for Ping frame events
Immediately send a Pong frame as a response upon receiving a Ping
Connection Maintenance
The server sends a Ping frame every 54 seconds
The client must reply with a Pong frame within a reasonable time
Continuous lack of response may lead to the connection being actively closed by the server
Implementation Example (Go)
Here is an example using the github.com/lxzan/gws library:
package main
import (
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/lxzan/gws"
)
func main() {
const addr = "wss://example.com/websocket-endpoint"
socket, _, err := gws.NewClient(new(WebSocket), &gws.ClientOption{
Addr: addr,
})
if err != nil {
log.Printf("error: %s\n", err.Error())
return
}
go socket.ReadLoop()
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
<-sigChan
}
type WebSocket struct{}
func (c *WebSocket) OnClose(socket *gws.Conn, err error) {
}
func (c *WebSocket) OnPong(socket *gws.Conn, payload []byte) {
}
func (c *WebSocket) OnOpen(socket *gws.Conn) {
}
func (c *WebSocket) OnPing(socket *gws.Conn, payload []byte) {
fmt.Printf("ping: %s\n", time.Now().Format(time.RFC3339))
_ = socket.WritePong(payload)
}
func (c *WebSocket) OnMessage(socket *gws.Conn, message *gws.Message) {
defer message.Close()
fmt.Printf("recv: %s\n", message.Data.String())
}
Key Implementation Points
OnPing method: Receives the server's Ping frame and calls socket.WritePong(payload) to reply
This library automatically handles the underlying Ping/Pong frame format and sending
Notes
Please ensure that your WebSocket client correctly handles Ping/Pong frames to maintain connection stability.