Handle ws errors on send/ping

This commit is contained in:
maciejhirsz
2018-07-26 17:25:29 +02:00
parent a8f0081385
commit 20d8b21adc
2 changed files with 23 additions and 3 deletions
+15 -2
View File
@@ -120,7 +120,13 @@ export default class Feed {
}
public sendData(data: FeedMessage.Data) {
this.socket.send(data);
try {
this.socket.send(data);
} catch (err) {
console.error('Failed to send data to a Feed', err);
this.disconnect();
}
}
public sendMessage(message: FeedMessage.Message) {
@@ -139,7 +145,14 @@ export default class Feed {
return;
}
this.waitingForPong = true;
this.socket.ping(noop);
try {
this.socket.ping(noop);
} catch (err) {
console.error('Failed to send ping to Feed', err);
this.disconnect();
}
}
private sendMessages = () => {
+8 -1
View File
@@ -243,7 +243,14 @@ export default class Node {
// }
this.pingStart = now;
this.socket.ping(noop);
try {
this.socket.ping(noop);
} catch (err) {
console.error('Failed to send ping to Node', err);
this.disconnect();
}
}
private updateBestBlock(update: BestBlock) {