mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
Don't recursively reconnect if the server sends a normal close
This commit is contained in:
parent
a05ff40e97
commit
7713d7f02f
1 changed files with 14 additions and 9 deletions
|
|
@ -64,16 +64,21 @@ function Setup_ws() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.onclose = function (event) {
|
ws.onclose = function (event) {
|
||||||
console.log ('onclose: reconnect');
|
if (event.code && event.code === 1000) {
|
||||||
ws = null;
|
console.log("WebSocket connection got normal close from server. Don't reconnect.");
|
||||||
ws = new WebSocket (adr + '?r=' + clog['connection_id']);
|
|
||||||
ws.onopen = function (event) {
|
|
||||||
console.log ('onclose: reconnect successful');
|
|
||||||
Setup_ws();
|
|
||||||
}
|
|
||||||
ws.onclose = function (event) {
|
|
||||||
console.log ('onclose: reconnect failure');
|
|
||||||
Shutdown_ws(event);
|
Shutdown_ws(event);
|
||||||
|
} else {
|
||||||
|
console.log ('onclose: reconnect');
|
||||||
|
ws = null;
|
||||||
|
ws = new WebSocket (adr + '?r=' + clog['connection_id']);
|
||||||
|
ws.onopen = function (event) {
|
||||||
|
console.log ('onclose: reconnect successful');
|
||||||
|
Setup_ws();
|
||||||
|
}
|
||||||
|
ws.onclose = function (event) {
|
||||||
|
console.log ('onclose: reconnect failure');
|
||||||
|
Shutdown_ws(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue