Skip to content

Commit

Permalink
Merge pull request #466 from minthauzens/master
Browse files Browse the repository at this point in the history
add ignore pong response to socketClient
  • Loading branch information
STRML authored May 10, 2021
2 parents 3867ee2 + d678c05 commit 556722b
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 556722b

Please sign in to comment.