I’m trying to send the following command to wss://fstream.binance.com/stream
to subscribe all depth messages:
{"id":9527,"method":"SUBSCRIBE","params":["btcusdt@depth@100ms","ethusdt@depth@100ms","bchusdt@depth@100ms","xrpusdt@depth@100ms","eosusdt@depth@100ms","ltcusdt@depth@100ms","trxusdt@depth@100ms","etcusdt@depth@100ms","linkusdt@depth@100ms","xlmusdt@depth@100ms","adausdt@depth@100ms","xmrusdt@depth@100ms","dashusdt@depth@100ms","zecusdt@depth@100ms","xtzusdt@depth@100ms","bnbusdt@depth@100ms","atomusdt@depth@100ms","ontusdt@depth@100ms","iotausdt@depth@100ms","batusdt@depth@100ms","vetusdt@depth@100ms","neousdt@depth@100ms","qtumusdt@depth@100ms","iostusdt@depth@100ms","thetausdt@depth@100ms","algousdt@depth@100ms","zilusdt@depth@100ms","kncusdt@depth@100ms","zrxusdt@depth@100ms","compusdt@depth@100ms","omgusdt@depth@100ms","dogeusdt@depth@100ms","sxpusdt@depth@100ms","kavausdt@depth@100ms","bandusdt@depth@100ms","rlcusdt@depth@100ms","wavesusdt@depth@100ms","mkrusdt@depth@100ms","snxusdt@depth@100ms","dotusdt@depth@100ms","defiusdt@depth@100ms","yfiusdt@depth@100ms","balusdt@depth@100ms","crvusdt@depth@100ms","trbusdt@depth@100ms","runeusdt@depth@100ms","sushiusdt@depth@100ms","srmusdt@depth@100ms","egldusdt@depth@100ms","solusdt@depth@100ms","icxusdt@depth@100ms","storjusdt@depth@100ms","blzusdt@depth@100ms","uniusdt@depth@100ms","avaxusdt@depth@100ms","ftmusdt@depth@100ms","hntusdt@depth@100ms","enjusdt@depth@100ms","flmusdt@depth@100ms","tomousdt@depth@100ms","renusdt@depth@100ms","ksmusdt@depth@100ms","nearusdt@depth@100ms","aaveusdt@depth@100ms","filusdt@depth@100ms","rsrusdt@depth@100ms","lrcusdt@depth@100ms","maticusdt@depth@100ms","oceanusdt@depth@100ms","cvcusdt@depth@100ms","belusdt@depth@100ms","ctkusdt@depth@100ms","axsusdt@depth@100ms","alphausdt@depth@100ms","zenusdt@depth@100ms","sklusdt@depth@100ms","grtusdt@depth@100ms","1inchusdt@depth@100ms","btcbusd@depth@100ms","akrousdt@depth@100ms","chzusdt@depth@100ms","sandusdt@depth@100ms","ankrusdt@depth@100ms","lunausdt@depth@100ms","btsusdt@depth@100ms","litusdt@depth@100ms","unfiusdt@depth@100ms","dodousdt@depth@100ms","reefusdt@depth@100ms","rvnusdt@depth@100ms","sfpusdt@depth@100ms","xemusdt@depth@100ms","cotiusdt@depth@100ms","chrusdt@depth@100ms","manausdt@depth@100ms","aliceusdt@depth@100ms","hbarusdt@depth@100ms","oneusdt@depth@100ms","linausdt@depth@100ms","stmxusdt@depth@100ms","dentusdt@depth@100ms","celrusdt@depth@100ms","hotusdt@depth@100ms","mtlusdt@depth@100ms","ognusdt@depth@100ms","nknusdt@depth@100ms","scusdt@depth@100ms","dgbusdt@depth@100ms","1000shibusdt@depth@100ms","icpusdt@depth@100ms","bakeusdt@depth@100ms","gtcusdt@depth@100ms","ethbusd@depth@100ms","btcdomusdt@depth@100ms","tlmusdt@depth@100ms","bnbbusd@depth@100ms","adabusd@depth@100ms","xrpbusd@depth@100ms","iotxusdt@depth@100ms","dogebusd@depth@100ms","audiousdt@depth@100ms","rayusdt@depth@100ms","c98usdt@depth@100ms","maskusdt@depth@100ms","atausdt@depth@100ms","solbusd@depth@100ms","fttbusd@depth@100ms","dydxusdt@depth@100ms","1000xecusdt@depth@100ms","galausdt@depth@100ms","celousdt@depth@100ms","arusdt@depth@100ms","klayusdt@depth@100ms","arpausdt@depth@100ms","ctsiusdt@depth@100ms","lptusdt@depth@100ms","ensusdt@depth@100ms","peopleusdt@depth@100ms","antusdt@depth@100ms","roseusdt@depth@100ms","duskusdt@depth@100ms","flowusdt@depth@100ms","imxusdt@depth@100ms","api3usdt@depth@100ms","ancusdt@depth@100ms","gmtusdt@depth@100ms","apeusdt@depth@100ms","bnxusdt@depth@100ms","woousdt@depth@100ms","fttusdt@depth@100ms","jasmyusdt@depth@100ms","darusdt@depth@100ms"]}
but I always get the error close 1006 (abnormal closure): unexpected EOF
in a few minutes.
Any ideas? Thanks!
My golang code is as the following:
package main
import (
"log"
"os"
"os/signal"
"strings"
"time"
"github.com/gorilla/websocket"
)
func main() {
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
stopCh := make(chan struct{})
c, _, err := websocket.DefaultDialer.Dial("wss://fstream.binance.com/stream", nil)
if err != nil {
log.Fatal("dial:", err)
}
defer c.Close()
err = c.WriteMessage(websocket.TextMessage, []byte(`{"id":9527,"method":"SUBSCRIBE","params":["btcusdt@depth@100ms","ethusdt@depth@100ms","bchusdt@depth@100ms","xrpusdt@depth@100ms","eosusdt@depth@100ms","ltcusdt@depth@100ms","trxusdt@depth@100ms","etcusdt@depth@100ms","linkusdt@depth@100ms","xlmusdt@depth@100ms","adausdt@depth@100ms","xmrusdt@depth@100ms","dashusdt@depth@100ms","zecusdt@depth@100ms","xtzusdt@depth@100ms","bnbusdt@depth@100ms","atomusdt@depth@100ms","ontusdt@depth@100ms","iotausdt@depth@100ms","batusdt@depth@100ms","vetusdt@depth@100ms","neousdt@depth@100ms","qtumusdt@depth@100ms","iostusdt@depth@100ms","thetausdt@depth@100ms","algousdt@depth@100ms","zilusdt@depth@100ms","kncusdt@depth@100ms","zrxusdt@depth@100ms","compusdt@depth@100ms","omgusdt@depth@100ms","dogeusdt@depth@100ms","sxpusdt@depth@100ms","kavausdt@depth@100ms","bandusdt@depth@100ms","rlcusdt@depth@100ms","wavesusdt@depth@100ms","mkrusdt@depth@100ms","snxusdt@depth@100ms","dotusdt@depth@100ms","defiusdt@depth@100ms","yfiusdt@depth@100ms","balusdt@depth@100ms","crvusdt@depth@100ms","trbusdt@depth@100ms","runeusdt@depth@100ms","sushiusdt@depth@100ms","srmusdt@depth@100ms","egldusdt@depth@100ms","solusdt@depth@100ms","icxusdt@depth@100ms","storjusdt@depth@100ms","blzusdt@depth@100ms","uniusdt@depth@100ms","avaxusdt@depth@100ms","ftmusdt@depth@100ms","hntusdt@depth@100ms","enjusdt@depth@100ms","flmusdt@depth@100ms","tomousdt@depth@100ms","renusdt@depth@100ms","ksmusdt@depth@100ms","nearusdt@depth@100ms","aaveusdt@depth@100ms","filusdt@depth@100ms","rsrusdt@depth@100ms","lrcusdt@depth@100ms","maticusdt@depth@100ms","oceanusdt@depth@100ms","cvcusdt@depth@100ms","belusdt@depth@100ms","ctkusdt@depth@100ms","axsusdt@depth@100ms","alphausdt@depth@100ms","zenusdt@depth@100ms","sklusdt@depth@100ms","grtusdt@depth@100ms","1inchusdt@depth@100ms","btcbusd@depth@100ms","akrousdt@depth@100ms","chzusdt@depth@100ms","sandusdt@depth@100ms","ankrusdt@depth@100ms","lunausdt@depth@100ms","btsusdt@depth@100ms","litusdt@depth@100ms","unfiusdt@depth@100ms","dodousdt@depth@100ms","reefusdt@depth@100ms","rvnusdt@depth@100ms","sfpusdt@depth@100ms","xemusdt@depth@100ms","cotiusdt@depth@100ms","chrusdt@depth@100ms","manausdt@depth@100ms","aliceusdt@depth@100ms","hbarusdt@depth@100ms","oneusdt@depth@100ms","linausdt@depth@100ms","stmxusdt@depth@100ms","dentusdt@depth@100ms","celrusdt@depth@100ms","hotusdt@depth@100ms","mtlusdt@depth@100ms","ognusdt@depth@100ms","nknusdt@depth@100ms","scusdt@depth@100ms","dgbusdt@depth@100ms","1000shibusdt@depth@100ms","icpusdt@depth@100ms","bakeusdt@depth@100ms","gtcusdt@depth@100ms","ethbusd@depth@100ms","btcdomusdt@depth@100ms","tlmusdt@depth@100ms","bnbbusd@depth@100ms","adabusd@depth@100ms","xrpbusd@depth@100ms","iotxusdt@depth@100ms","dogebusd@depth@100ms","audiousdt@depth@100ms","rayusdt@depth@100ms","c98usdt@depth@100ms","maskusdt@depth@100ms","atausdt@depth@100ms","solbusd@depth@100ms","fttbusd@depth@100ms","dydxusdt@depth@100ms","1000xecusdt@depth@100ms","galausdt@depth@100ms","celousdt@depth@100ms","arusdt@depth@100ms","klayusdt@depth@100ms","arpausdt@depth@100ms","ctsiusdt@depth@100ms","lptusdt@depth@100ms","ensusdt@depth@100ms","peopleusdt@depth@100ms","antusdt@depth@100ms","roseusdt@depth@100ms","duskusdt@depth@100ms","flowusdt@depth@100ms","imxusdt@depth@100ms","api3usdt@depth@100ms","ancusdt@depth@100ms","gmtusdt@depth@100ms","apeusdt@depth@100ms","bnxusdt@depth@100ms","woousdt@depth@100ms","fttusdt@depth@100ms","jasmyusdt@depth@100ms","darusdt@depth@100ms"]}`))
if err != nil {
log.Fatal(err)
}
ticker := time.NewTicker(15 * time.Second) // send a unsolicited pong frame every 15 seconds
begin_time := time.Now()
for {
select {
case <-interrupt:
log.Println("interrupt")
close(stopCh)
ticker.Stop()
return
case <-ticker.C:
log.Printf("%v sending a unsolicited pong frame, has been running for %v seconds", time.Now().Format(time.RFC3339), time.Since(begin_time).Seconds())
err = c.WriteMessage(websocket.PongMessage, nil)
if err != nil {
log.Fatal(err)
}
default:
_, message, err := c.ReadMessage()
if err != nil {
log.Fatal("Error reading due to ", err)
} else {
txt := string(message)
if !strings.Contains(txt, "depthUpdate") {
log.Printf("recv: %s", txt)
}
}
}
}
}