diff --git a/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java b/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java index 43319573632..835fe66f66c 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java +++ b/jetty-core/jetty-websocket/jetty-websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/WebSocketCoreSession.java @@ -317,11 +317,21 @@ public class WebSocketCoreSession implements CoreSession, Dumpable CloseStatus closeStatus = new CloseStatus(code, cause); if (CloseStatus.isTransmittableStatusCode(code)) + { close(closeStatus, callback); + } else { if (sessionState.onClosed(closeStatus)) + { closeConnection(closeStatus, callback); + } + else + { + // We are already closed because of a previous failure. + // Succeed because failing might re-enter this branch if it's the Frame callback. + callback.succeeded(); + } } }