Removed check node up from WS #3587
This commit is contained in:
parent
bb6fe16478
commit
0c3d87f0d3
@ -101,16 +101,6 @@ export default class Ws extends JsonRpcBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkNodeUp () {
|
|
||||||
return fetch('/', { method: 'HEAD' })
|
|
||||||
.then((r) => {
|
|
||||||
return r.status === 200;
|
|
||||||
}, () => {
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
.catch(() => false);
|
|
||||||
}
|
|
||||||
|
|
||||||
_onOpen = (event) => {
|
_onOpen = (event) => {
|
||||||
console.log('ws:onOpen', event);
|
console.log('ws:onOpen', event);
|
||||||
this._connected = true;
|
this._connected = true;
|
||||||
@ -127,16 +117,6 @@ export default class Ws extends JsonRpcBase {
|
|||||||
this._connected = false;
|
this._connected = false;
|
||||||
this._connecting = false;
|
this._connecting = false;
|
||||||
|
|
||||||
this._checkNodeUp()
|
|
||||||
.then((up) => {
|
|
||||||
// If the connection has been closed and the node
|
|
||||||
// is up, it means we have a wrong token
|
|
||||||
// Event code 1006 for WS means there is an error
|
|
||||||
// (not just closed by server)
|
|
||||||
if (up && event.code === 1006) {
|
|
||||||
event.status = 403;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._lastError = event;
|
this._lastError = event;
|
||||||
|
|
||||||
if (this._autoConnect) {
|
if (this._autoConnect) {
|
||||||
@ -156,7 +136,6 @@ export default class Ws extends JsonRpcBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('ws:onClose', event);
|
console.log('ws:onClose', event);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onError = (event) => {
|
_onError = (event) => {
|
||||||
|
@ -41,6 +41,15 @@ export default class SecureApi extends Api {
|
|||||||
console.log('SecureApi:setToken', this._transport.token);
|
console.log('SecureApi:setToken', this._transport.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_checkNodeUp () {
|
||||||
|
return fetch('/', { method: 'HEAD' })
|
||||||
|
.then(
|
||||||
|
(r) => r.status === 200,
|
||||||
|
() => false
|
||||||
|
)
|
||||||
|
.catch(() => false);
|
||||||
|
}
|
||||||
|
|
||||||
_followConnection = () => {
|
_followConnection = () => {
|
||||||
const nextTick = () => {
|
const nextTick = () => {
|
||||||
if (this._followConnectionTimeoutId) {
|
if (this._followConnectionTimeoutId) {
|
||||||
@ -65,17 +74,23 @@ export default class SecureApi extends Api {
|
|||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
return this.connectSuccess();
|
return this.connectSuccess();
|
||||||
} else if (lastError) {
|
} else if (lastError) {
|
||||||
|
return this
|
||||||
|
._checkNodeUp()
|
||||||
|
.then((isNodeUp) => {
|
||||||
const nextToken = this._tokensToTry[0] || 'initial';
|
const nextToken = this._tokensToTry[0] || 'initial';
|
||||||
const nextState = nextToken !== 'initial' ? 0 : 1;
|
const nextState = nextToken !== 'initial' ? 0 : 1;
|
||||||
|
|
||||||
// If previous token was wrong, delete it
|
// If previous token was wrong (error while node up), delete it
|
||||||
if (lastError.status === 403) {
|
if (isNodeUp) {
|
||||||
this._tokensToTry = this._tokensToTry.slice(1);
|
this._tokensToTry = this._tokensToTry.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextToken !== this._transport.token) {
|
if (nextToken !== this._transport.token) {
|
||||||
this.updateToken(nextToken, nextState);
|
this.updateToken(nextToken, nextState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextTick();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user