{"record":{"id":"06948589f610d2f5","repo":"eclipse-vertx/vert.x","slug":"websocket-is-closed","errorCode":null,"errorMessage":"WebSocket is closed","messagePattern":"WebSocket is closed","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/http/impl/websocket/WebSocketImplBase.java","lineNumber":341,"sourceCode":"        return new BinaryWebSocketFrame(frame.isFinal(), 0, buf);\n      case TEXT:\n        return new TextWebSocketFrame(frame.isFinal(), 0, buf);\n      case CLOSE:\n        return new CloseWebSocketFrame(true, 0, buf);\n      case CONTINUATION:\n        return new ContinuationWebSocketFrame(frame.isFinal(), 0, buf);\n      case PONG:\n        return new PongWebSocketFrame(buf);\n      case PING:\n        return new PingWebSocketFrame(buf);\n      default:\n        throw new IllegalStateException(\"Unsupported WebSocket msg \" + frame);\n    }\n  }\n\n  void checkClosed() {\n    if (isClosed()) {\n      throw new IllegalStateException(\"WebSocket is closed\");\n    }\n  }\n\n  public boolean isClosed() {\n    synchronized (this) {\n      return closed || closeStatusCode != null;\n    }\n  }\n\n  void handleFrame(WebSocketFrameInternal frame) {\n    switch (frame.type()) {\n      case PING:\n        // Echo back the content of the PING frame as PONG frame as specified in RFC 6455 Section 5.5.2\n        conn.writeToChannel(new PongWebSocketFrame(frame.getBinaryData().copy()));\n        break;\n      case PONG:\n        Handler<Buffer> pongHandler = pongHandler();\n        if (pongHandler != null) {","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/http/impl/websocket/WebSocketImplBase.java#L323-L359","documentation":"Lifecycle guard in WebSocketImplBase.checkClosed: an operation (registering handlers, checking writeQueueFull, etc.) was attempted after the WebSocket was closed. The generic sentinel fires whenever isClosed() is true, preventing interaction with a dead socket.","triggerScenarios":"Thrown at vertx-core/src/main/java/io/vertx/core/http/impl/websocket/WebSocketImplBase.java:341 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register handlers before the socket closes and stop using it afterwards","React to the closeHandler to halt pending operations","Route post-close errors through your failure handling instead of the throw path"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}