{"record":{"id":"3b3d061d205bb82b","repo":"eclipse-vertx/vert.x","slug":"reconnect-interval-must-be-1","errorCode":null,"errorMessage":"reconnect interval must be >= 1","messagePattern":"reconnect interval must be >= 1","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/NetClientOptions.java","lineNumber":304,"sourceCode":"    return this;\n  }\n\n  /**\n   * @return  the value of reconnect attempts\n   */\n  public int getReconnectAttempts() {\n    return reconnectAttempts;\n  }\n\n  /**\n   * Set the reconnect interval\n   *\n   * @param interval  the reconnect interval in ms\n   * @return a reference to this, so the API can be used fluently\n   */\n  public NetClientOptions setReconnectInterval(long interval) {\n    if (interval < 1) {\n      throw new IllegalArgumentException(\"reconnect interval must be >= 1\");\n    }\n    this.reconnectInterval = interval;\n    return this;\n  }\n\n  /**\n   * @return  the value of the hostname verification algorithm\n   */\n  public String getHostnameVerificationAlgorithm() {\n    ClientSSLOptions o = getSslOptions();\n    return o != null ? o.getHostnameVerificationAlgorithm() : DEFAULT_HOSTNAME_VERIFICATION_ALGORITHM;\n  }\n\n  /**\n   * Set the hostname verification algorithm interval\n   * To disable hostname verification, set hostnameVerificationAlgorithm to an empty String\n   *\n   * @param hostnameVerificationAlgorithm should be HTTPS, LDAPS or an empty String","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/NetClientOptions.java#L286-L322","documentation":"NetClientOptions.setReconnectInterval(long) requires an interval of at least 1 millisecond; passing 0 or a negative number throws IllegalArgumentException. The interval is the delay between reconnection attempts.","triggerScenarios":"Calling setReconnectInterval(0) or setReconnectInterval(-1000), or a JSON config with reconnectInterval <= 0 processed via fromJson.","commonSituations":"Using 0 hoping for 'reconnect immediately'; negative values from configuration placeholders or unfilled templates; unit confusion (seconds vs milliseconds) producing 0 after truncation.","solutions":["Pass a positive long, e.g. 1000 for 1 second","Clamp: Math.max(1, interval) before calling","Correct the config value to be >= 1"],"exampleFix":"// before\noptions.setReconnectInterval(0);\n// after\noptions.setReconnectInterval(2000); // 2s between attempts","handlingStrategy":"validation","validationCode":"long interval = configuredInterval;\nif (interval < 1) {\n  throw new IllegalArgumentException(\"reconnectInterval must be >= 1\");\n}\noptions.setReconnectInterval(interval);","typeGuard":"boolean isValidReconnectInterval(long ms) { return ms >= 1; }","tryCatchPattern":null,"preventionTips":["Never use 0 to mean 'immediate reconnect' - pick a small positive value like 100ms","Check units (ms) when converting from seconds or minutes","Validate config-driven longs at load time"],"tags":["validation","reconnect","netclient","config"],"backgroundTag":"value-out-of-range","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"}