Invalid WebSocket frame: invalid status code 1

{

error: {
message: Invalid WebSocket frame: invalid status code 1,
name: RangeError,
stack:
RangeError: Invalid WebSocket frame: invalid status code 1
at Receiver.controlMessage (/home/bitnami/dice-test/node_modules/ws/lib/receiver.js:464:18)
at Receiver.getData (/home/bitnami/dice-test/node_modules/ws/lib/receiver.js:350:42)
at Receiver.startLoop (/home/bitnami/dice-test/node_modules/ws/lib/receiver.js:143:22)
at /home/bitnami/dice-test/node_modules/ws/lib/receiver.js:397:12
at /home/bitnami/dice-test/node_modules/ws/lib/permessage-deflate.js:308:9
at /home/bitnami/dice-test/node_modules/ws/lib/permessage-deflate.js:386:7
at afterWrite (_stream_writable.js:490:5)
at onwrite (_stream_writable.js:470:7)
at InflateRaw.afterTransform (_stream_transform.js:98:3)
at Zlib.processCallback (zlib.js:585:8)
},
message: Invalid WebSocket frame: invalid status code 1,
target: {
_binaryType: nodebuffer,
_bufferedAmount: 0,
_closeCode: 1002,
_closeFrameReceived: False,
_closeFrameSent: False,
_closeMessage: ,
_closeTimer: None,
_events: [Object],
_eventsCount: 2,
_extensions: [Object],
_isServer: False,
_maxListeners: [undefined],
_protocol: ,
_readyState: 2,
_receiver: [Object],
_redirects: 0,
_req: None,
_sender: [Object],
_socket: [Object],
_url: wss://fstream.binance.com/ws/aaveusdt@kline_1h
},
type: error
}

I got this error using Binance future WebSocket while fetching kline data

I have the same issue, can you solve the issue?

Hi.
I’m not so sure if you use any library or not but this might be a programming error since the raw url works fine.

It works just fine. However, sometimes the WebSocket stream throws this error. Maybe because I listen to too many streams (above 100) in a single socket connection?

This error only occurs for a short period of time. Also, I use NodeJS with “ws” library for socket handling.

Listen to up to 200 streams should be fine. https://binance-docs.github.io/apidocs/futures/en/#websocket-market-streams
Maybe you can keep an eye on the error message Invalid WebSocket frame: invalid status code 1 to see where the status code is defined and used.