mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: support Master Node crash
parent
f36da68598
commit
a135ea0aec
|
@ -67,6 +67,7 @@ let platform: PlatformUtils;
|
||||||
export class OpenVidu {
|
export class OpenVidu {
|
||||||
|
|
||||||
private jsonRpcClient: any;
|
private jsonRpcClient: any;
|
||||||
|
private masterNodeHasCrashed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
|
@ -744,7 +745,8 @@ export class OpenVidu {
|
||||||
onconnected: onConnectSucces,
|
onconnected: onConnectSucces,
|
||||||
ondisconnect: this.disconnectCallback.bind(this),
|
ondisconnect: this.disconnectCallback.bind(this),
|
||||||
onreconnecting: this.reconnectingCallback.bind(this),
|
onreconnecting: this.reconnectingCallback.bind(this),
|
||||||
onreconnected: this.reconnectedCallback.bind(this)
|
onreconnected: this.reconnectedCallback.bind(this),
|
||||||
|
ismasternodecrashed: this.isMasterNodeCrashed.bind(this)
|
||||||
},
|
},
|
||||||
rpc: {
|
rpc: {
|
||||||
requestTimeout: 10000,
|
requestTimeout: 10000,
|
||||||
|
@ -761,12 +763,23 @@ export class OpenVidu {
|
||||||
networkQualityLevelChanged: this.session.onNetworkQualityLevelChangedChanged.bind(this.session),
|
networkQualityLevelChanged: this.session.onNetworkQualityLevelChangedChanged.bind(this.session),
|
||||||
filterEventDispatched: this.session.onFilterEventDispatched.bind(this.session),
|
filterEventDispatched: this.session.onFilterEventDispatched.bind(this.session),
|
||||||
iceCandidate: this.session.recvIceCandidate.bind(this.session),
|
iceCandidate: this.session.recvIceCandidate.bind(this.session),
|
||||||
mediaError: this.session.onMediaError.bind(this.session)
|
mediaError: this.session.onMediaError.bind(this.session),
|
||||||
|
masterNodeCrashedNotification: this.onMasterNodeCrashedNotification.bind(this)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.jsonRpcClient = new RpcBuilder.clients.JsonRpcClient(config);
|
this.jsonRpcClient = new RpcBuilder.clients.JsonRpcClient(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
onMasterNodeCrashedNotification(response): void {
|
||||||
|
console.error('Master Node has crashed');
|
||||||
|
this.masterNodeHasCrashed = true;
|
||||||
|
this.session.onLostConnection("nodeCrashed");
|
||||||
|
this.jsonRpcClient.close(4103, "Master Node has crashed");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
|
@ -1009,10 +1022,14 @@ export class OpenVidu {
|
||||||
if (!!this.session.connection) {
|
if (!!this.session.connection) {
|
||||||
this.sendRequest('connect', { sessionId: this.session.connection.rpcSessionId }, (error, response) => {
|
this.sendRequest('connect', { sessionId: this.session.connection.rpcSessionId }, (error, response) => {
|
||||||
if (!!error) {
|
if (!!error) {
|
||||||
logger.error(error);
|
if (this.isMasterNodeCrashed()) {
|
||||||
logger.warn('Websocket was able to reconnect to OpenVidu Server, but your Connection was already destroyed due to timeout. You are no longer a participant of the Session and your media streams have been destroyed');
|
logger.warn('Master Node has crashed!');
|
||||||
this.session.onLostConnection("networkDisconnect");
|
} else {
|
||||||
this.jsonRpcClient.close(4101, "Reconnection fault");
|
logger.error(error);
|
||||||
|
logger.warn('Websocket was able to reconnect to OpenVidu Server, but your Connection was already destroyed due to timeout. You are no longer a participant of the Session and your media streams have been destroyed');
|
||||||
|
this.session.onLostConnection("networkDisconnect");
|
||||||
|
this.jsonRpcClient.close(4101, "Reconnection fault");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.jsonRpcClient.resetPing();
|
this.jsonRpcClient.resetPing();
|
||||||
this.session.onRecoveredConnection();
|
this.session.onRecoveredConnection();
|
||||||
|
@ -1030,6 +1047,10 @@ export class OpenVidu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isMasterNodeCrashed() {
|
||||||
|
return this.masterNodeHasCrashed;
|
||||||
|
}
|
||||||
|
|
||||||
private isRoomAvailable(): boolean {
|
private isRoomAvailable(): boolean {
|
||||||
if (this.session !== undefined && this.session instanceof Session) {
|
if (this.session !== undefined && this.session instanceof Session) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue