{"record":{"id":"073a37987e19a3f5","repo":"eclipse-vertx/vert.x","slug":"connecttimeout-must-be-0-or-1-use-default-cli","errorCode":null,"errorMessage":"connectTimeout must be >= 0 or -1 (use default client value)","messagePattern":"connectTimeout must be >= 0 or -1 \\(use default client value\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/ConnectOptions.java","lineNumber":222,"sourceCode":"  }\n\n  /**\n   * @return the value of connect timeout in millis or {@code -1} when using the client defined connect timeout {@link NetClientOptions#getConnectTimeout()}\n   */\n  public int getTimeout() {\n    return timeout;\n  }\n\n  /**\n   * Override the client connect timeout in millis when {@code timeout >= 0} or use the client defined connect timeout {@link NetClientOptions#getConnectTimeout()}\n   * when {@code timeout == -1}.\n   *\n   * @param timeout connect timeout, in ms\n   * @return a reference to this, so the API can be used fluently\n   */\n  public ConnectOptions setTimeout(int timeout) {\n    if (timeout < -2) {\n      throw new IllegalArgumentException(\"connectTimeout must be >= 0 or -1 (use default client value)\");\n    }\n    this.timeout = timeout;\n    return this;\n  }\n}\n","sourceCodeStart":204,"sourceCodeEnd":228,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/ConnectOptions.java#L204-L228","documentation":"Configuration validation in ConnectOptions.setTimeout: the per-connection override of the client connect timeout must be >= 0 or exactly -1 (sentinel meaning 'use the client's configured connect timeout'). Any other negative value is rejected.","triggerScenarios":"Thrown at vertx-core/src/main/java/io/vertx/core/net/ConnectOptions.java:222 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass -1 to defer to the client default, or a value >= 0","Validate user-supplied timeout overrides before applying"],"exampleFix":null,"handlingStrategy":"validation","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"}