mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: try to delete any ghost participant after unknown ws close
parent
276722176b
commit
96907f2c7f
|
@ -155,6 +155,13 @@ public class OpenViduServer implements JsonRpcConfigurer {
|
||||||
return new RpcHandler();
|
return new RpcHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
@DependsOn("rpcHandler")
|
||||||
|
public RpcNotificationService notificationService(RpcHandler rpcHandler) {
|
||||||
|
return new RpcNotificationService(rpcHandler);
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@DependsOn("openviduConfig")
|
@DependsOn("openviduConfig")
|
||||||
|
@ -189,12 +196,6 @@ public class OpenViduServer implements JsonRpcConfigurer {
|
||||||
return new DummyLoadManager();
|
return new DummyLoadManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public RpcNotificationService notificationService() {
|
|
||||||
return new RpcNotificationService();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public KurentoParticipantEndpointConfig kurentoEndpointConfig() {
|
public KurentoParticipantEndpointConfig kurentoEndpointConfig() {
|
||||||
|
|
|
@ -19,10 +19,8 @@ package io.openvidu.server.core;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.kurento.client.GenericMediaEvent;
|
import org.kurento.client.GenericMediaEvent;
|
||||||
|
|
|
@ -45,6 +45,12 @@ public class RpcNotificationService {
|
||||||
private ScheduledExecutorService closeWsScheduler = Executors
|
private ScheduledExecutorService closeWsScheduler = Executors
|
||||||
.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
|
.newScheduledThreadPool(Runtime.getRuntime().availableProcessors());
|
||||||
|
|
||||||
|
private RpcHandler rpcHandler;
|
||||||
|
|
||||||
|
public RpcNotificationService(RpcHandler rpcHandler) {
|
||||||
|
this.rpcHandler = rpcHandler;
|
||||||
|
}
|
||||||
|
|
||||||
public RpcConnection newRpcConnection(Transaction t, Request<JsonObject> request) {
|
public RpcConnection newRpcConnection(Transaction t, Request<JsonObject> request) {
|
||||||
String participantPrivateId = t.getSession().getSessionId();
|
String participantPrivateId = t.getSession().getSessionId();
|
||||||
RpcConnection connection = new RpcConnection(t.getSession());
|
RpcConnection connection = new RpcConnection(t.getSession());
|
||||||
|
@ -118,9 +124,18 @@ public class RpcNotificationService {
|
||||||
try {
|
try {
|
||||||
s.sendNotification(method, params);
|
s.sendNotification(method, params);
|
||||||
} catch (KurentoException e) {
|
} catch (KurentoException e) {
|
||||||
|
|
||||||
if (e.getCause() instanceof IllegalStateException) {
|
if (e.getCause() instanceof IllegalStateException) {
|
||||||
log.warn("Notification '{}' couldn't be sent to participant with privateId {}: {}", method,
|
log.warn("Notification '{}' couldn't be sent to participant with privateId {}: {}", method,
|
||||||
participantPrivateId, e.getCause().getMessage());
|
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 {
|
} else {
|
||||||
log.error("Exception sending notification '{}': {} to participant with private id {}", method, params,
|
log.error("Exception sending notification '{}': {} to participant with private id {}", method, params,
|
||||||
participantPrivateId, e);
|
participantPrivateId, e);
|
||||||
|
|
Loading…
Reference in New Issue