{"record":{"id":"c63364054425f6af","repo":"eclipse-vertx/vert.x","slug":"scheme","errorCode":null,"errorMessage":"Scheme: ","messagePattern":"Scheme: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/http/WebSocketConnectOptions.java","lineNumber":310,"sourceCode":"    return this;\n  }\n\n  @Override\n  public WebSocketConnectOptions setAbsoluteURI(URL url) {\n    URI uri;\n    try {\n      uri = url.toURI();\n    } catch (URISyntaxException e) {\n      throw new IllegalArgumentException(e);\n    }\n    setAbsoluteURI(uri);\n    return this;\n  }\n\n  private void setAbsoluteURI(URI uri) {\n    String scheme = uri.getScheme();\n    if (!\"ws\".equals(scheme) && !\"wss\".equals(scheme)) {\n      throw new IllegalArgumentException(\"Scheme: \" + scheme);\n    }\n    boolean ssl = scheme.length() == 3;\n    int port = uri.getPort();\n    if (port == -1) {\n      port = ssl ? 443 : 80;\n    };\n    StringBuilder relativeUri = new StringBuilder();\n    if (uri.getRawPath() != null) {\n      relativeUri.append(uri.getRawPath());\n    }\n    if (uri.getRawQuery() != null) {\n      relativeUri.append('?').append(uri.getRawQuery());\n    }\n    if (uri.getRawFragment() != null) {\n      relativeUri.append('#').append(uri.getRawFragment());\n    }\n    setHost(uri.getHost());\n    setPort(port);","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/http/WebSocketConnectOptions.java#L292-L328","documentation":"WebSocketConnectOptions.setAbsoluteURI parses an absolute URI and requires the scheme to be exactly 'ws' or 'wss'. Any other scheme (http, https, ftp, or a missing one) throws this IllegalArgumentException. Vert.x WebSockets only connect over the ws/wss schemes.","triggerScenarios":"Calling new WebSocketConnectOptions().setAbsoluteURI(\"https://example.com/ws\") or \"example.com/socket\" (no scheme); also triggered internally when a URI object passed to setAbsoluteURI(URI) has a non-ws scheme.","commonSituations":"Reusing an HTTP endpoint URL string for a WebSocket connection; forgetting the scheme entirely; building the URI from config where the scheme is http by default; typing ws:// wrong after copy-paste from a browser URL.","solutions":["Change the scheme to ws:// (or wss:// for TLS), e.g. setAbsoluteURI(\"wss://example.com/ws\").","If you have an http(s) URL, replace the scheme programmatically before passing it.","Always include the scheme — a scheme-less URI also fails this check."],"exampleFix":"// before\nWebSocketConnectOptions opts = new WebSocketConnectOptions().setAbsoluteURI(\"https://example.com/events\");\n// after\nWebSocketConnectOptions opts = new WebSocketConnectOptions().setAbsoluteURI(\"wss://example.com/events\");","handlingStrategy":"validation","validationCode":"static String toWsScheme(String url) {\n  return url.replaceFirst(\"^https?://\", m -> url.startsWith(\"https\") ? \"wss://\" : \"ws://\");\n}\n// ensure url starts with \"ws://\" or \"wss://\" before setAbsoluteURI","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never reuse http(s) endpoint URLs directly for WebSocket connections.","Centralize WebSocket URL construction in one helper that enforces ws/wss.","Include the scheme in configuration values, don't rely on defaults."],"tags":["websocket","url","scheme"],"backgroundTag":"invalid-url-format","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"}