openvidu-server: try to delete any ghost participant after unknown ws close

pull/820/head
pabloFuente 2023-09-28 14:24:52 +02:00
parent 276722176b
commit 96907f2c7f
3 changed files with 22 additions and 8 deletions

View File

@ -155,6 +155,13 @@ public class OpenViduServer implements JsonRpcConfigurer {
return new RpcHandler();
}
@Bean
@ConditionalOnMissingBean
@DependsOn("rpcHandler")
public RpcNotificationService notificationService(RpcHandler rpcHandler) {
return new RpcNotificationService(rpcHandler);
}
@Bean
@ConditionalOnMissingBean
@DependsOn("openviduConfig")
@ -189,12 +196,6 @@ public class OpenViduServer implements JsonRpcConfigurer {
return new DummyLoadManager();
}
@Bean
@ConditionalOnMissingBean
public RpcNotificationService notificationService() {
return new RpcNotificationService();
}
@Bean
@ConditionalOnMissingBean
public KurentoParticipantEndpointConfig kurentoEndpointConfig() {

View File

@ -19,10 +19,8 @@ package io.openvidu.server.core;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.kurento.client.GenericMediaEvent;

View File

@ -45,6 +45,12 @@ public class RpcNotificationService {
private ScheduledExecutorService closeWsScheduler = Executors
.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
private RpcHandler rpcHandler;
public RpcNotificationService(RpcHandler rpcHandler) {
this.rpcHandler = rpcHandler;
}
public RpcConnection newRpcConnection(Transaction t, Request<JsonObject> request) {
String participantPrivateId = t.getSession().getSessionId();
RpcConnection connection = new RpcConnection(t.getSession());
@ -118,9 +124,18 @@ public class RpcNotificationService {
try {
s.sendNotification(method, params);
} catch (KurentoException e) {
if (e.getCause() instanceof IllegalStateException) {
log.warn("Notification '{}' couldn't be sent to participant with privateId {}: {}", method,
participantPrivateId, e.getCause().getMessage());
// TODO: this is an ad-hoc fix to clean any ghost participant of sessions
if (e.getCause().getMessage() != null && e.getCause().getMessage().contains(
"has been closed and no method (apart from close()) may be called on a closed session")) {
log.warn("Removing ghost participant with participant private id {}", participantPrivateId);
this.rpcHandler.leaveRoomAfterConnClosed(participantPrivateId, null);
}
} else {
log.error("Exception sending notification '{}': {} to participant with private id {}", method, params,
participantPrivateId, e);