Skip to content

Commit

Permalink
add ignore pong response to socketClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Valters committed Dec 7, 2020
1 parent aa55e7f commit d678c05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions official-ws/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,13 @@ DEBUG=* node example.js
# Display all high-level debug messages
DEBUG=BitMEX:* node example.js
```

### Heartbeat
https://www.bitmex.com/app/wsAPI#Heartbeats

you can implement a more thorough solution, but hope this helps along
```
setInterval(() => {
client.socket.send("ping")
}, 30 * 1000); // sends ping every 30 s
```
3 changes: 3 additions & 0 deletions official-ws/nodejs/lib/createSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ module.exports = function createSocket(options, bmexClient) {

wsClient.onmessage = function(data) {
try {
if (data === "pong") {
return;
}
data = JSON.parse(data);
debug('Received %j', data);
} catch(e) {
Expand Down

0 comments on commit d678c05

Please sign in to comment.