JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.03k stars 425 forks source link

Websocket client fails to subscribe to market data stream on spot testnet with message "System.Exception: unknown server protocol version" #557

Closed deadheadblues closed 3 years ago

deadheadblues commented 3 years ago

Describe the bug BinanceSocketClient object is unable to subscribe to market data stream on the spot testnet. Same code works on the Binance.US api.

To Reproduce To reproduce, create a BinanceSocketClient and try to subscribe to a market data stream on the spot testnet.

Expected behavior The expected behavior is for the BinanceSocketClient to receive market updates after successfully subscribing to market data streams.

Debug logging 2021/01/20 16:32:45:688 | Binance | Debug | Client configuration: LogVerbosity: Debug, Writers: 1, Credentials: Set, BaseAddress: https://testnet.binance.vision/, Proxy: -, RateLimiters: 0, RateLimitBehaviour: Wait, RequestTimeout: 00:00:30 2021/01/20 16:32:45:720 | Binance | Debug | Client configuration: LogVerbosity: Debug, Writers: 1, Credentials: Set, BaseAddress: wss://testnet.binance.vision/ws/, Proxy: -, AutoReconnect: True, ReconnectInterval: 00:00:05, SocketResponseTimeout: 00:00:10, SocketSubscriptionsCombineTarget: 2021/01/20 16:32:53:296 | Binance | Debug | Created new socket for wss://testnet.binance.vision/ws/stream?streams=bnbusdt@bookTicker 2021/01/20 16:32:53:325 | Binance | Debug | Socket 1 connecting 2021/01/20 16:32:54:038 | Binance | Info | Socket 1 error: System.Exception: unknown server protocol version 2021/01/20 16:32:54:063 | Binance | Debug | Socket 1 connection failed, state: Connecting 2021/01/20 16:32:54:070 | Binance | Info | Socket 1 closed 2021/01/20 16:32:54:077 | Binance | Debug | Socket 1 disposing websocket 2021/01/20 16:32:54:087 | Binance | Debug | Created new socket for wss://testnet.binance.vision/ws/stream?streams=bnbusdt@trade 2021/01/20 16:32:54:089 | Binance | Debug | Socket 2 connecting 2021/01/20 16:32:54:824 | Binance | Info | Socket 2 error: System.Exception: unknown server protocol version 2021/01/20 16:32:54:826 | Binance | Debug | Socket 2 connection failed, state: Connecting 2021/01/20 16:32:54:827 | Binance | Info | Socket 2 closed 2021/01/20 16:32:54:828 | Binance | Debug | Socket 2 disposing websocket 2021/01/20 16:32:54:834 | Binance | Debug | Created new socket for wss://testnet.binance.vision/ws/stream?streams=bnbusdt@kline_1d 2021/01/20 16:32:54:858 | Binance | Debug | Socket 3 connecting 2021/01/20 16:32:56:327 | Binance | Info | Socket 3 error: System.Exception: unknown server protocol version 2021/01/20 16:32:56:328 | Binance | Debug | Socket 3 connection failed, state: Connecting 2021/01/20 16:32:56:328 | Binance | Info | Socket 3 closed 2021/01/20 16:32:56:329 | Binance | Debug | Socket 3 disposing websocket

JKorf commented 3 years ago

Hi, I think the issue is in the base address you've configured. I'm able to reproduce your issue when using wss://testnet.binance.vision/ws/. It works for me when using just wss://testnet.binance.vision/, without the /ws post-fix. Hope that helps.

deadheadblues commented 3 years ago

Thank you! That was indeed the issue.