Commit 4102e483 authored by Robert Knight's avatar Robert Knight

Improve field name

This is a count of the number of reconnections, not including the
initial connection attempt.
parent d9a017a2
...@@ -59,7 +59,7 @@ export class StreamerService { ...@@ -59,7 +59,7 @@ export class StreamerService {
* Number of automatic reconnection attempts that have been made following * Number of automatic reconnection attempts that have been made following
* an unexpected disconnection. * an unexpected disconnection.
*/ */
this._connectionAttempts = 0; this._reconnectionAttempts = 0;
this._reconnectSetUp = false; this._reconnectSetUp = false;
} }
...@@ -202,16 +202,16 @@ export class StreamerService { ...@@ -202,16 +202,16 @@ export class StreamerService {
const newSocket = new Socket(url); const newSocket = new Socket(url);
newSocket.on('open', () => { newSocket.on('open', () => {
this._connectionAttempts = 0; this._reconnectionAttempts = 0;
this._sendClientConfig(newSocket); this._sendClientConfig(newSocket);
}); });
newSocket.on('disconnect', () => { newSocket.on('disconnect', () => {
++this._connectionAttempts; ++this._reconnectionAttempts;
if (this._connectionAttempts < 10) { if (this._reconnectionAttempts < 10) {
// Reconnect with a delay that doubles on each attempt. // Reconnect with a delay that doubles on each attempt.
// This reduces the stampede of requests if the WebSocket server has a // This reduces the stampede of requests if the WebSocket server has a
// problem. // problem.
const delay = 1000 * 2 ** this._connectionAttempts; const delay = 1000 * 2 ** this._reconnectionAttempts;
setTimeout(() => this._reconnect(), delay); setTimeout(() => this._reconnect(), delay);
} else { } else {
console.error( console.error(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment