mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: nodeCrashed event
parent
2569e935ff
commit
cf062c8950
|
@ -21,6 +21,6 @@ public enum CDREventName {
|
||||||
|
|
||||||
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated,
|
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated,
|
||||||
webrtcConnectionDestroyed, recordingStarted, recordingStopped, recordingStatusChanged, filterEventDispatched,
|
webrtcConnectionDestroyed, recordingStarted, recordingStopped, recordingStatusChanged, filterEventDispatched,
|
||||||
signalSent, mediaNodeStatusChanged, autoscaling, mediaServerCrashed
|
signalSent, mediaNodeStatusChanged, autoscaling, nodeCrashed
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import io.openvidu.server.kurento.kms.Kms;
|
import io.openvidu.server.kurento.kms.Kms;
|
||||||
|
|
||||||
public class CDREventMediaServerCrashed extends CDREvent {
|
public class CDREventNodeCrashed extends CDREvent {
|
||||||
|
|
||||||
private Kms kms;
|
private Kms kms;
|
||||||
private String environmentId;
|
private String environmentId;
|
||||||
|
|
||||||
public CDREventMediaServerCrashed(CDREventName eventName, String sessionId, Long timeStamp, Kms kms,
|
public CDREventNodeCrashed(CDREventName eventName, String sessionId, Long timeStamp, Kms kms,
|
||||||
String environmentId) {
|
String environmentId) {
|
||||||
super(eventName, sessionId, timeStamp);
|
super(eventName, sessionId, timeStamp);
|
||||||
this.kms = kms;
|
this.kms = kms;
|
|
@ -217,9 +217,9 @@ public class CallDetailRecord {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordMediaServerCrashed(Kms kms, String environmentId, long timeOfKurentoDisconnection) {
|
public void recordNodeCrashed(Kms kms, String environmentId, long timeOfKurentoDisconnection) {
|
||||||
CDREvent e = new CDREventMediaServerCrashed(CDREventName.mediaServerCrashed, null, timeOfKurentoDisconnection,
|
CDREvent e = new CDREventNodeCrashed(CDREventName.nodeCrashed, null, timeOfKurentoDisconnection, kms,
|
||||||
kms, environmentId);
|
environmentId);
|
||||||
this.log(e);
|
this.log(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package io.openvidu.server.core;
|
||||||
public enum EndReason {
|
public enum EndReason {
|
||||||
|
|
||||||
unsubscribe, unpublish, disconnect, forceUnpublishByUser, forceUnpublishByServer, forceDisconnectByUser,
|
unsubscribe, unpublish, disconnect, forceUnpublishByUser, forceUnpublishByServer, forceDisconnectByUser,
|
||||||
forceDisconnectByServer, lastParticipantLeft, networkDisconnect, mediaServerDisconnect, mediaServerCrashed,
|
forceDisconnectByServer, lastParticipantLeft, networkDisconnect, mediaServerDisconnect, nodeCrashed,
|
||||||
openviduServerStopped, recordingStoppedByServer, automaticStop, sessionClosedByServer
|
openviduServerStopped, recordingStoppedByServer, automaticStop, sessionClosedByServer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -607,8 +607,11 @@ public class SessionEventsHandler {
|
||||||
public void onConnectionPropertyChanged(Participant participant, String property, Object newValue) {
|
public void onConnectionPropertyChanged(Participant participant, String property, Object newValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMediaServerCrashed(Kms kms, long timeOfKurentoDisconnection) {
|
public void onMediaNodeCrashed(Kms kms, long timeOfKurentoDisconnection) {
|
||||||
CDR.recordMediaServerCrashed(kms, null, timeOfKurentoDisconnection);
|
CDR.recordNodeCrashed(kms, null, timeOfKurentoDisconnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMasterNodeCrashed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<Participant> filterParticipantsByRole(OpenViduRole[] roles, Set<Participant> participants) {
|
protected Set<Participant> filterParticipantsByRole(OpenViduRole[] roles, Set<Participant> participants) {
|
||||||
|
|
|
@ -198,29 +198,43 @@ public abstract class KmsManager {
|
||||||
kms.getUri(), kms.getKurentoClient().toString());
|
kms.getUri(), kms.getKurentoClient().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
final int loops = 6;
|
// 6 attempts, 2 times per second (3 seconds total)
|
||||||
|
final int maxReconnectTimeMillis = 3000;
|
||||||
|
final int intervalWaitMs = 500;
|
||||||
|
final int loops = maxReconnectTimeMillis / intervalWaitMs;
|
||||||
final AtomicInteger iteration = new AtomicInteger(loops);
|
final AtomicInteger iteration = new AtomicInteger(loops);
|
||||||
final long intervalWaitMs = 500L;
|
|
||||||
|
final long initTime = System.currentTimeMillis();
|
||||||
|
|
||||||
final UpdatableTimerTask kurentoClientReconnectTimer = new UpdatableTimerTask(() -> {
|
final UpdatableTimerTask kurentoClientReconnectTimer = new UpdatableTimerTask(() -> {
|
||||||
if (iteration.decrementAndGet() < 0) {
|
if (iteration.decrementAndGet() < 0) {
|
||||||
|
|
||||||
log.error("KurentoClient [{}] could not reconnect to KMS with uri {} in {} seconds",
|
log.error(
|
||||||
kms.getKurentoClient().toString(), kms.getUri(), (intervalWaitMs * 6 / 1000));
|
"KurentoClient [{}] could not reconnect to KMS with uri {} in {} seconds. Media Node crashed",
|
||||||
|
kms.getKurentoClient().toString(), kms.getUri(), (intervalWaitMs * loops / 1000));
|
||||||
kms.getKurentoClientReconnectTimer().cancelTimer();
|
kms.getKurentoClientReconnectTimer().cancelTimer();
|
||||||
|
|
||||||
|
final long timeOfKurentoDisconnection = kms.getTimeOfKurentoClientDisconnection();
|
||||||
|
sessionEventsHandler.onMediaNodeCrashed(kms, timeOfKurentoDisconnection);
|
||||||
|
|
||||||
log.warn("Closing {} sessions hosted by KMS with uri {}: {}", kms.getKurentoSessions().size(),
|
log.warn("Closing {} sessions hosted by KMS with uri {}: {}", kms.getKurentoSessions().size(),
|
||||||
kms.getUri(), kms.getKurentoSessions().stream().map(s -> s.getSessionId())
|
kms.getUri(), kms.getKurentoSessions().stream().map(s -> s.getSessionId())
|
||||||
.collect(Collectors.joining(",", "[", "]")));
|
.collect(Collectors.joining(",", "[", "]")));
|
||||||
|
|
||||||
final long timeOfKurentoDisconnection = kms.getTimeOfKurentoClientDisconnection();
|
|
||||||
sessionEventsHandler.onMediaServerCrashed(kms, timeOfKurentoDisconnection);
|
|
||||||
|
|
||||||
kms.getKurentoSessions().forEach(kSession -> {
|
kms.getKurentoSessions().forEach(kSession -> {
|
||||||
sessionManager.closeSession(kSession.getSessionId(), EndReason.mediaServerCrashed);
|
sessionManager.closeSession(kSession.getSessionId(), EndReason.nodeCrashed);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// KurentoClient connection timeout may exceed the limit.
|
||||||
|
// This happens if not only kms process has crashed, but the instance itself is
|
||||||
|
// not reachable
|
||||||
|
if ((System.currentTimeMillis() - initTime) > maxReconnectTimeMillis) {
|
||||||
|
iteration.set(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
kms.getKurentoClient().getServerManager().getInfo();
|
kms.getKurentoClient().getServerManager().getInfo();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -256,7 +270,7 @@ public abstract class KmsManager {
|
||||||
|
|
||||||
kms.setTimeOfKurentoClientDisconnection(0);
|
kms.setTimeOfKurentoClientDisconnection(0);
|
||||||
}
|
}
|
||||||
}, () -> intervalWaitMs); // Try 2 times per seconds
|
}, () -> Long.valueOf(intervalWaitMs)); // Try 2 times per seconds
|
||||||
|
|
||||||
kms.setKurentoClientReconnectTimer(kurentoClientReconnectTimer);
|
kms.setKurentoClientReconnectTimer(kurentoClientReconnectTimer);
|
||||||
kurentoClientReconnectTimer.updateTimer();
|
kurentoClientReconnectTimer.updateTimer();
|
||||||
|
|
|
@ -1097,7 +1097,7 @@
|
||||||
],
|
],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"mode": "raw",
|
||||||
"raw": "{\n \"OPENVIDU_SECRET\":\"MY_SECRET\",\n \"OPENVIDU_CDR\":true,\n \"OPENVIDU_RECORDING\":true,\n \"OPENVIDU_RECORDING_PUBLIC_ACCESS\":true,\n \"OPENVIDU_RECORDING_NOTIFICATION\":\"publisher_moderator\",\n \"OPENVIDU_RECORDING_PATH\":\"/opt/openvidu/recordings\",\n \"OPENVIDU_RECORDING_CUSTOM_LAYOUT\":\"/opt/openvidu/custom-layout\",\n \"OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT\":120,\n \"OPENVIDU_WEBHOOK\":false,\n \"OPENVIDU_WEBHOOK_ENDPOINT\":\"http://localhost:7777/webhook/\",\n \"OPENVIDU_WEBHOOK_HEADERS\":[\n \"Authorization: Basic T1BFTlZJRFVBUFA6TVlfU0VDUkVU\"\n ],\n \"OPENVIDU_WEBHOOK_EVENTS\":[\n \"recordingStatusChanged\"\n ],\n \"OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH\":1000,\n \"OPENVIDU_STREAMS_VIDEO_MIN_RECV_BANDWIDTH\":300,\n \"OPENVIDU_STREAMS_VIDEO_MAX_SEND_BANDWIDTH\":1000,\n \"OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH\":300,\n \"OPENVIDU_SESSIONS_GARBAGE_INTERVAL\":900,\n \"OPENVIDU_SESSIONS_GARBAGE_THRESHOLD\":3600,\n \"OPENVIDU_PRO_STATS_MONITORING_INTERVAL\":30,\n \"OPENVIDU_PRO_STATS_WEBRTC_INTERVAL\":20\n}"
|
"raw": "{\n \"OPENVIDU_SECRET\":\"MY_SECRET\",\n \"OPENVIDU_CDR\":true,\n \"OPENVIDU_RECORDING\":true,\n \"OPENVIDU_RECORDING_PUBLIC_ACCESS\":true,\n \"OPENVIDU_RECORDING_NOTIFICATION\":\"publisher_moderator\",\n \"OPENVIDU_RECORDING_PATH\":\"/opt/openvidu/recordings\",\n \"OPENVIDU_RECORDING_CUSTOM_LAYOUT\":\"/opt/openvidu/custom-layout\",\n \"OPENVIDU_RECORDING_AUTOSTOP_TIMEOUT\":120,\n \"OPENVIDU_WEBHOOK\":false,\n \"OPENVIDU_WEBHOOK_ENDPOINT\":\"http://localhost:7777/webhook/\",\n \"OPENVIDU_WEBHOOK_HEADERS\":[\n \"Authorization: Basic T1BFTlZJRFVBUFA6TVlfU0VDUkVU\"\n ],\n \"OPENVIDU_WEBHOOK_EVENTS\":[\n \"recordingStatusChanged\"\n ],\n \"OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH\":1000,\n \"OPENVIDU_STREAMS_VIDEO_MIN_RECV_BANDWIDTH\":300,\n \"OPENVIDU_STREAMS_VIDEO_MAX_SEND_BANDWIDTH\":1000,\n \"OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH\":300,\n \"OPENVIDU_SESSIONS_GARBAGE_INTERVAL\":900,\n \"OPENVIDU_SESSIONS_GARBAGE_THRESHOLD\":3600,\n \"OPENVIDU_PRO_STATS_MONITORING_INTERVAL\":10,\n \"OPENVIDU_PRO_STATS_WEBRTC_INTERVAL\":20\n}"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "https://localhost:4443/openvidu/api/restart",
|
"raw": "https://localhost:4443/openvidu/api/restart",
|
||||||
|
|
|
@ -24,7 +24,7 @@ OPENVIDU_CDR_PATH=/opt/openvidu/cdr
|
||||||
OPENVIDU_WEBHOOK=false
|
OPENVIDU_WEBHOOK=false
|
||||||
OPENVIDU_WEBHOOK_ENDPOINT=
|
OPENVIDU_WEBHOOK_ENDPOINT=
|
||||||
OPENVIDU_WEBHOOK_HEADERS=[]
|
OPENVIDU_WEBHOOK_HEADERS=[]
|
||||||
OPENVIDU_WEBHOOK_EVENTS=["sessionCreated","sessionDestroyed","participantJoined","participantLeft","webrtcConnectionCreated","webrtcConnectionDestroyed","recordingStatusChanged","filterEventDispatched","signalSent","mediaNodeStatusChanged","autoscaling","mediaServerCrashed"]
|
OPENVIDU_WEBHOOK_EVENTS=["sessionCreated","sessionDestroyed","participantJoined","participantLeft","webrtcConnectionCreated","webrtcConnectionDestroyed","recordingStatusChanged","filterEventDispatched","signalSent","mediaNodeStatusChanged","autoscaling","nodeCrashed"]
|
||||||
|
|
||||||
OPENVIDU_RECORDING=false
|
OPENVIDU_RECORDING=false
|
||||||
OPENVIDU_RECORDING_DEBUG=false
|
OPENVIDU_RECORDING_DEBUG=false
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
server.port=7777
|
server.port=7777
|
||||||
server.ssl.enabled=false
|
server.ssl.enabled=false
|
||||||
|
management.metrics.export.elastic.enabled=false
|
Loading…
Reference in New Issue