{"record":{"id":"68aeeaf3632e83d4","repo":"TooTallNate/Java-WebSocket","slug":"this-draft-does-not-support-sec-websocket-protocol","errorCode":null,"errorMessage":"This draft does not support Sec-WebSocket-Protocol","messagePattern":"This draft does not support Sec-WebSocket-Protocol","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/java_websocket/WebSocketImpl.java","lineNumber":888,"sourceCode":"    return channel instanceof ISSLChannel;\n  }\n\n  @Override\n  public SSLSession getSSLSession() {\n    if (!hasSSLSupport()) {\n      throw new IllegalArgumentException(\n          \"This websocket uses ws instead of wss. No SSLSession available.\");\n    }\n    return ((ISSLChannel) channel).getSSLEngine().getSession();\n  }\n\n  @Override\n  public IProtocol getProtocol() {\n    if (draft == null) {\n      return null;\n    }\n    if (!(draft instanceof Draft_6455)) {\n      throw new IllegalArgumentException(\"This draft does not support Sec-WebSocket-Protocol\");\n    }\n    return ((Draft_6455) draft).getProtocol();\n  }\n\n  @Override\n  public <T> void setAttachment(T attachment) {\n    this.attachment = attachment;\n  }\n\n  public ByteChannel getChannel() {\n    return channel;\n  }\n\n  public void setChannel(ByteChannel channel) {\n    this.channel = channel;\n  }\n\n  public WebSocketWorker getWorkerThread() {","sourceCodeStart":870,"sourceCodeEnd":906,"githubUrl":"https://github.com/TooTallNate/Java-WebSocket/blob/afeacbf8c0f6f6a761c9d9daed8c813dd3b8ed7d/src/main/java/org/java_websocket/WebSocketImpl.java#L870-L906","documentation":"Thrown by WebSocketImpl.getProtocol() when the connection's negotiated draft is not Draft_6455. Protocol (subprotocol) negotiation via the Sec-WebSocket-Protocol header only exists in the RFC 6455 draft; older drafts (Draft_75/76/Hybi) carry no protocols, so querying getProtocol() on such a connection is a programming error rather than returning null. Fires only for non-6455 drafts with a non-null draft.","triggerScenarios":"Thrown at src/main/java/org/java_websocket/WebSocketImpl.java:888 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the negotiated draft before calling getProtocol(), e.g. `if (conn.getDraft() instanceof Draft_6455)`.","Always use Draft_6455 (the default) on client and server so subprotocols are available.","If no protocols may exist, treat a null return from getProtocol() (draft == null case) as 'unknown' instead of forcing a query on an unsupported draft."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}