Skip to content

Commit

Permalink
Fixed server reconnection bug
Browse files Browse the repository at this point in the history
  • Loading branch information
baxy committed Feb 17, 2019
1 parent d232f17 commit 918091c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ export default class Server {

this.socket = new PrimusSocket(`${this.url}`, {
reconnect: {
min: 1 + (Math.floor(Math.random() * 10)), // Random between 1 and 10 seconds
min: (1 + (Math.floor(Math.random() * 10))) * 1000, // Random between 1 and 10 seconds
factor: 1,
retries: 300 // Retries for 25 hours
retries: 8640
}
});

Expand Down Expand Up @@ -225,7 +225,10 @@ export default class Server {
}

destroy() {
this.socket.destroy();
if (this.socket) {
this.socket.destroy();
}

clearInterval(this.pingIntervalId);
clearInterval(this.checkLastBlockInterval);
}
Expand Down

0 comments on commit 918091c

Please sign in to comment.