Hi,
I have set everything up with websockets and all is fine if I connect to;
./exe wss://fstream.binance.com/ws/btcusdt@ticker
My socket connection is esablished and handler called ok.
Received: {“e”:“24hrTicker”,“E”:1702742074270,“s”:“BTCUSDT”,“p”:“652.30”,“P”:“1.558”,“w”:“42149.75”,“c”:“42519.00”,“Q”:“0.006”,“o”:“41866.70”,“h”:“42577.00”,“l”:“41638.10”,“v”:“185779.441”,“q”:“7830556909.16”,“O”:1702655640000,“C”:1702742074269,“F”:4383430762,“L”:4385556923,“n”:2126134}
Thats fine.
However if I connect to;
wss://fstream.binance.com/ws (or indeed wss://fstream.binance.com/ws/ )
I connect OK but keep getting an “invalid state” back. The output below illustrates that my SUBSCRIBE message is fine (looks ok to me) and that before doing the send, I am successfully connected to websocket.
Successfully connected to: wss://fstream.binance.com/ws
sending: {
“method”: “SUBSCRIBE”,
“params”: [
{
“symbol”: “btcusdt@ticker”
}
],
“id”: 23 }
Error sending subscribe: invalid state
Running websocket: wss://fstream.binance.com/ws
[2023-12-16 15:56:57] [connect] Successful connection
[2023-12-16 15:56:58] [connect] WebSocket Connection 52.192.113.82:443 v-2 “WebSocket++/0.8.2” /ws 101
Can anybody shed light PLEASE
“Connected” above means that
_connection = _tls_client.get_connection(_endpoint.c_str(), _ec);
_tls_client.connect(_connection);
_tls_client.run();
have all completed OK.
I am fairly sure the message I’m sending has to be the source of it but I’m stumped.
Thanks much for any help. Its wrecking my head!!
Graham