Skip to content

Commit

Permalink
ADD: throws onError if keepalive ping does not return in 9 sec
Browse files Browse the repository at this point in the history
  • Loading branch information
Overtorment committed Aug 20, 2020
1 parent cc018ef commit 0945300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ class ElectrumClient extends Client {
}
this.timeout = setTimeout(() => {
if (this.timeLastCall !== 0 && new Date().getTime() > this.timeLastCall + 5000) {
const pingTimer = setTimeout(() => {
this.onError(new Error('keepalive ping timeout'));
}, 9000);
this.server_ping().catch((reason) => {
console.log('keepalive ping failed because of', reason);
});
clearTimeout(pingTimer);
}).then(() => clearTimeout(pingTimer));
}
}, 5000);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electrum-client",
"version": "1.1.3",
"version": "1.1.4",
"description": "Electrum protocol client for React Native & Node.js",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 0945300

Please sign in to comment.