mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: update reconnection handler to catch uncaught KurentoException
parent
2f41d27b62
commit
72b8e78dff
|
@ -34,6 +34,7 @@ import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.kurento.client.KurentoClient;
|
import org.kurento.client.KurentoClient;
|
||||||
|
import org.kurento.commons.exception.KurentoException;
|
||||||
import org.kurento.jsonrpc.JsonRpcClientClosedException;
|
import org.kurento.jsonrpc.JsonRpcClientClosedException;
|
||||||
import org.kurento.jsonrpc.client.JsonRpcClientNettyWebSocket;
|
import org.kurento.jsonrpc.client.JsonRpcClientNettyWebSocket;
|
||||||
import org.kurento.jsonrpc.client.JsonRpcWSConnectionListener;
|
import org.kurento.jsonrpc.client.JsonRpcWSConnectionListener;
|
||||||
|
@ -329,24 +330,37 @@ public abstract class KmsManager {
|
||||||
try {
|
try {
|
||||||
kms.getKurentoClient().getServerManager().getInfo();
|
kms.getKurentoClient().getServerManager().getInfo();
|
||||||
return true;
|
return true;
|
||||||
} catch (JsonRpcClientClosedException e) {
|
} catch (JsonRpcClientClosedException exception) {
|
||||||
log.error(
|
log.error(
|
||||||
"According to Timer KurentoClient [{}] of KMS with uri {} is closed ({}). Initializing a new KurentoClient",
|
"According to Timer KurentoClient [{}] of KMS with uri {} is closed ({}). Initializing a new KurentoClient",
|
||||||
kms.getKurentoClient().toString(), kms.getUri(), e.getClass().getName());
|
kms.getKurentoClient().toString(), kms.getUri(), exception.getClass().getName());
|
||||||
KurentoClient kClient = createKurentoClient(kms.getId(), kms.getUri());
|
KurentoClient kClient = null;
|
||||||
|
try {
|
||||||
|
kClient = createKurentoClient(kms.getId(), kms.getUri());
|
||||||
|
} catch (KurentoException e) {
|
||||||
|
log.error("Error creating new KurentoClient when connectig to KMS with uri {}. Exception {}: {}",
|
||||||
|
kms.getUri(), e.getClass().getName(), e.getMessage());
|
||||||
|
if (kClient != null) {
|
||||||
|
kClient.destroy();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
kClient.getServerManager().getInfo();
|
kClient.getServerManager().getInfo();
|
||||||
kms.setKurentoClient(kClient);
|
kms.setKurentoClient(kClient);
|
||||||
log.info("Success reconnecting to KMS with uri {} with a new KurentoClient", kms.getUri());
|
log.info("Success reconnecting to KMS with uri {} with a new KurentoClient", kms.getUri());
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e2) {
|
} catch (Exception e) {
|
||||||
log.error("Error reconnecting to KMS with uri {} with a new KurentoClient. Exception {}: {}",
|
log.error("Error reconnecting to KMS with uri {} with a new KurentoClient. Exception {}: {}",
|
||||||
kms.getUri(), e2.getClass().getName(), e2.getMessage());
|
kms.getUri(), e.getClass().getName(), e.getMessage());
|
||||||
|
if (kClient != null) {
|
||||||
|
kClient.destroy();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception exception) {
|
||||||
log.error("According to Timer KMS with uri {} and KurentoClient [{}] is not reconnected yet. Exception {}",
|
log.error("According to Timer KMS with uri {} and KurentoClient [{}] is not reconnected yet. Exception {}",
|
||||||
kms.getUri(), kms.getKurentoClient().toString(), e.getClass().getName());
|
kms.getUri(), kms.getKurentoClient().toString(), exception.getClass().getName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,10 @@ public class UpdatableTimerTask extends TimerTask {
|
||||||
|
|
||||||
public void cancelTimer() {
|
public void cancelTimer() {
|
||||||
super.cancel();
|
super.cancel();
|
||||||
timer.cancel();
|
if (timer != null) {
|
||||||
timer.purge();
|
timer.cancel();
|
||||||
|
timer.purge();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -321,7 +321,7 @@ public class OpenViduTestE2e {
|
||||||
BrowserUser browserUser = null;
|
BrowserUser browserUser = null;
|
||||||
GenericContainer<?> container;
|
GenericContainer<?> container;
|
||||||
Path path;
|
Path path;
|
||||||
|
|
||||||
switch (browser) {
|
switch (browser) {
|
||||||
case "chrome":
|
case "chrome":
|
||||||
container = chromeContainer("selenium/standalone-chrome:" + CHROME_VERSION, 2147483648L, 1, true);
|
container = chromeContainer("selenium/standalone-chrome:" + CHROME_VERSION, 2147483648L, 1, true);
|
||||||
|
@ -715,7 +715,7 @@ public class OpenViduTestE2e {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMediafilePath(Path path) throws Exception {
|
private void checkMediafilePath(Path path) throws Exception {
|
||||||
if (!Files.exists(path)) {
|
if (!Files.exists(path)) {
|
||||||
throw new Exception("File " + path.toAbsolutePath().toString() + " does not exist");
|
throw new Exception("File " + path.toAbsolutePath().toString() + " does not exist");
|
||||||
|
@ -724,4 +724,8 @@ public class OpenViduTestE2e {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getRandom(Set<String> set) {
|
||||||
|
return set.stream().skip((int) (set.size() * Math.random())).findFirst().get();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue