Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ 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'));
if (this.timeout != null) {
this.onError(new Error('keepalive ping timeout'));
}
}, 9000);
this.server_ping().catch((reason) => {
console.log('keepalive ping failed because of', reason);
Expand All @@ -75,6 +77,7 @@ class ElectrumClient extends Client {
super.close();
if (this.timeout != null) {
clearTimeout(this.timeout);
this.timeout = null;
}
this.reconnect = this.reconnect = this.onClose = this.keepAlive = () => {}; // dirty hack to make it stop reconnecting
}
Expand Down