Open sergiocard opened 2 years ago
Thanks for the details - seems like the websocket object in browsers doesn't have that method. I wonder if it's not necessary in browser environments (where websocket lifecycles behave slightly differently)...
This is the line that's calling terminate() https://github.com/tiagosiebler/binance/blob/master/src/websocket-client.ts#L363
Also I wonder if it's the heartbeat mechanism thinking that the websocket dropped. I haven't yet added a way to turn off the heartbeat mechanism completely (but I plan in doing so), but in the meantime you can try to increase the heartbeat interval to a large number.
Set pingInterval: number
to a high value - it's in milliseconds and controls how often the ws client sends a heartbeat to the server. You can also increase how much time you allow for the heartbeat to get a reply from the exchange server, which should reduce the chances of this happening: pongTimeout: number
- this is also in milliseconds.
https://github.com/tiagosiebler/binance/blob/master/src/websocket-client.ts#L48-L49
Will be fixed in the next release (2.0.18), available shortly. Please let me know once you've had a chance to test.
tested. Terminate undefined function error not present but after a few seconds, It tries to ping binance but an error occurs. You can view the used code and error log on following attached image
Ah I see - I don't think the heartbeat mechanism will work at all in the browser, although perhaps it's also not necessary there. You can disable it as of the latest version by passing disableHeartbeat: true
in the constructor of the websocket-client. That'll prevent the connector from trying to use these methods in the heartbeat mechanism, more intended for backend environments.
Hi all i'm trying following code installing this lib on react browser app.
The websocket is connected successfully and receive data on network but after some seconds i get this error:
that correspond to the following source code:
it seems the close function is called and terminate() method is not present into _b object