Avoid reconnection check when KurentoClient explicitly closed

pull/431/head
micaelgallego 2020-04-09 17:15:38 +02:00
parent 8c1703aa54
commit 5f3902d973
1 changed files with 21 additions and 5 deletions

View File

@ -203,9 +203,15 @@ public abstract class KmsManager {
public void disconnected() { public void disconnected() {
final Kms kms = kmss.get(kmsId); final Kms kms = kmss.get(kmsId);
log.info("Kurento Client \"disconnected\" event for KMS {} [{}]", kms.getUri(), if(kms.getKurentoClient().isClosed()) {
kms.getKurentoClient().toString()); log.info("Kurento Client \"disconnected\" event for KMS {} [{}]. Closed explicitely", kms.getUri(),
kms.getKurentoClient().toString());
return;
} else {
log.info("Kurento Client \"disconnected\" event for KMS {} [{}]. Waiting reconnection", kms.getUri(),
kms.getKurentoClient().toString());
}
kms.setKurentoClientConnected(false); kms.setKurentoClientConnected(false);
kms.setTimeOfKurentoClientDisconnection(System.currentTimeMillis()); kms.setTimeOfKurentoClientDisconnection(System.currentTimeMillis());
@ -219,16 +225,26 @@ public abstract class KmsManager {
try { try {
if (kmsReconnectionLocks.get(kms.getId()).tryLock(5, TimeUnit.SECONDS)) { if (kmsReconnectionLocks.get(kms.getId()).tryLock(5, TimeUnit.SECONDS)) {
lockAcquired = true; lockAcquired = true;
if (kms.isKurentoClientConnected()) { if (kms.isKurentoClientConnected()) {
// reconnected listener already executed // reconnected listener already executed
log.warn( log.info(
"Timer of KMS with uri {} and KurentoClient [{}] cancelled (reconnected event received during interval wait)", "Timer of KMS with uri {} and KurentoClient [{}] cancelled (reconnected event received during interval wait)",
kms.getUri(), kms.getKurentoClient().toString()); kms.getUri(), kms.getKurentoClient().toString());
timer.cancel(); timer.cancel();
return; return;
} }
if(kms.getKurentoClient().isClosed()) {
log.info(
"Timer of KMS with uri {} and KurentoClient [{}] has been closed. Cancelling Timer",
kms.getUri(), kms.getKurentoClient().toString());
timer.cancel();
return;
}
kms.getKurentoClient().getServerManager().getInfo(); kms.getKurentoClient().getServerManager().getInfo();
log.warn("According to Timer KMS with uri {} and KurentoClient [{}] is now reconnected", log.info("According to Timer KMS with uri {} and KurentoClient [{}] is now reconnected",
kms.getUri(), kms.getKurentoClient().toString()); kms.getUri(), kms.getKurentoClient().toString());
timer.cancel(); timer.cancel();
kms.setKurentoClientConnected(true); kms.setKurentoClientConnected(true);