diff --git a/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java b/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java index ca7cc0a1..67705037 100644 --- a/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java +++ b/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java @@ -183,8 +183,11 @@ private void closeClient(UUID sessionId, Channel channel) { } catch (Throwable t) { log.warn("Can't close channel for sessionId: {}", sessionId, t); } - ClientHead clientHead = clientsBox.removeClient(sessionId); - clientHead.disconnect(); + ClientHead clientHead = clientsBox.get(sessionId); + if (clientHead != null && clientHead.getNamespaces().isEmpty()) { + clientsBox.removeClient(sessionId); + clientHead.disconnect(); + } log.info("Client with sessionId: {} was disconnected", sessionId); }