{"record":{"id":"4d6470a9dc0ed51a","repo":"TooTallNate/Java-WebSocket","slug":"bad-rsv-rsv1-rsv1-rsv2-rsv2-rsv3-rsv3-4d6470","errorCode":null,"errorMessage":"bad rsv RSV1: {rsv1} RSV2: {rsv2} RSV3: {rsv3}","messagePattern":"bad rsv RSV1: (.+?) RSV2: (.+?) RSV3: (.+?)","errorType":"exception","errorClass":"InvalidFrameException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/java_websocket/extensions/DefaultExtension.java","lineNumber":64,"sourceCode":"  @Override\n  public void encodeFrame(Framedata inputFrame) {\n    //Nothing to do here\n  }\n\n  @Override\n  public boolean acceptProvidedExtensionAsServer(String inputExtension) {\n    return true;\n  }\n\n  @Override\n  public boolean acceptProvidedExtensionAsClient(String inputExtension) {\n    return true;\n  }\n\n  @Override\n  public void isFrameValid(Framedata inputFrame) throws InvalidDataException {\n    if (inputFrame.isRSV1() || inputFrame.isRSV2() || inputFrame.isRSV3()) {\n      throw new InvalidFrameException(\n          \"bad rsv RSV1: \" + inputFrame.isRSV1() + \" RSV2: \" + inputFrame.isRSV2() + \" RSV3: \"\n              + inputFrame.isRSV3());\n    }\n  }\n\n  @Override\n  public String getProvidedExtensionAsClient() {\n    return \"\";\n  }\n\n  @Override\n  public String getProvidedExtensionAsServer() {\n    return \"\";\n  }\n\n  @Override\n  public IExtension copyInstance() {\n    return new DefaultExtension();","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/TooTallNate/Java-WebSocket/blob/afeacbf8c0f6f6a761c9d9daed8c813dd3b8ed7d/src/main/java/org/java_websocket/extensions/DefaultExtension.java#L46-L82","documentation":"DefaultExtension.isFrameValid is the base validation for extensions with no negotiated RSV usage: it rejects any frame with RSV1, RSV2, or RSV3 set, throwing InvalidFrameException (close code 1002, PROTOCOL_ERROR). This is the generic 'RSV bits set but no extension negotiated to use them' violation required by RFC 6455.","triggerScenarios":"A peer sets any RSV bit (e.g. RSV1=1 implying permessage-deflate) on a connection where only DefaultExtension is negotiated — i.e. the client offered the extension but the server declined it, or the client sets RSV bits without offering the extension at all.","commonSituations":"Client always marks frames compressed but the server has no compression extension in its draft (new Draft_6455() without extensions); mismatched drafts between client and server after a library upgrade; proxies stripping the Sec-WebSocket-Extensions header so negotiation silently fails.","solutions":["Enable the compression extension on the server: new Draft_6455(Collections.singletonList(new PerMessageDeflateExtension()))","Ensure client and server drafts negotiate the same extensions (check Sec-WebSocket-Extensions in the handshake)","If no compression is intended, fix the peer to send frames with all RSV bits cleared","Note this exact call also appears in tests (testIsFrameValid); when writing extensions, override isFrameValid to allow the RSV bits your extension owns"],"exampleFix":"// before: server draft without extensions, client sends RSV1 frames\nWebSocketServer wss = new WebSocketServer(addr, Collections.singletonList(new Draft_6455()));\n// after\nDraft_6455 draft = new Draft_6455(Collections.singletonList(new PerMessageDeflateExtension()));\nWebSocketServer wss = new WebSocketServer(addr, Collections.singletonList(draft));","handlingStrategy":"try-catch","validationCode":"// verify extension negotiation before relying on RSV1 compression\nString ext = responseHeader(\"Sec-WebSocket-Extensions\");\nboolean deflateNegotiated = ext != null && ext.contains(\"permessage-deflate\");\nif (!deflateNegotiated) { compressFrames = false; }","typeGuard":null,"tryCatchPattern":"@Override public void onClose(int code, String reason, boolean remote) {\n  if (code == 1002 && reason.startsWith(\"bad rsv\")) {\n    // peer sent RSV bits but no extension was negotiated\n    reconnectWithoutCompression();\n  }\n}","preventionTips":["Configure matching extensions on both client and server drafts","Check Sec-WebSocket-Extensions in the handshake to confirm negotiation","If compression is not needed, ensure clients clear all RSV bits","When writing a custom extension, override isFrameValid to permit the RSV bits you own"],"tags":["websocket","rsv-bits","extension-negotiation","protocol-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"afeacbf8c0f6f6a761c9d9daed8c813dd3b8ed7d","analyzedAt":"2026-09-09T14:39:47.546Z","contentChangedAt":"2026-09-09T14:39:47.546Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}