alibaba/nacos · critical · IllegalArgumentException
[http-client] invalid connect timeout:{}
Error message
[http-client] invalid connect timeout:{} What it means
Thrown during static initialization of ParamUtil when the NACOS.CONNECT.TIMEOUT property is set to a non-integer value (IllegalArgumentException). ParamUtil reads the timeout from NacosClientProperties, parses it with Integer.parseInt, and fails fast if the value is not a valid integer. This is a JVM-startup-time error — the exception propagates from the static initializer, causing the ParamUtil class to fail initialization.
Source
Thrown at client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java:72
LOGGER.info("[settings] [http-client] connect timeout:{}", connectTimeout);
readTimeout = initReadTimeout();
LOGGER.info("[settings] [http-client] read timeout:{}", readTimeout);
perTaskConfigSize = initPerTaskConfigSize();
LOGGER.info("PER_TASK_CONFIG_SIZE: {}", perTaskConfigSize);
}
private static int initConnectionTimeout() {
String tmp = DEFAULT_NACOS_CONNECT_TIMEOUT;
try {
tmp = NacosClientProperties.PROTOTYPE.getProperty(NACOS_CONNECT_TIMEOUT_KEY,
DEFAULT_NACOS_CONNECT_TIMEOUT);
return Integer.parseInt(tmp);
} catch (NumberFormatException e) {
final String msg = "[http-client] invalid connect timeout:" + tmp;
LOGGER.error("[settings] " + msg, e);
throw new IllegalArgumentException(msg, e);
}
}
private static int initReadTimeout() {
String tmp = DEFAULT_NACOS_READ_TIMEOUT;
try {
tmp = NacosClientProperties.PROTOTYPE.getProperty(NACOS_READ_TIMEOUT_KEY,
DEFAULT_NACOS_READ_TIMEOUT);
return Integer.parseInt(tmp);
} catch (NumberFormatException e) {
final String msg = "[http-client] invalid read timeout:" + tmp;
LOGGER.error("[settings] " + msg, e);
throw new IllegalArgumentException(msg, e);
}
}
private static double initPerTaskConfigSize() {
try {View on GitHub (pinned to 9b989acdf1)
Solutions
- Set NACOS.CONNECT.TIMEOUT to a plain integer (milliseconds), e.g., -DNACOS.CONNECT.TIMEOUT=2000.
- Remove the property entirely to use the default (1000ms).
- Check all property sources (system properties, environment variables, nacos-client.properties file) for an incorrect NACOS.CONNECT.TIMEOUT value.
Example fix
# before -DNACOS.CONNECT.TIMEOUT=2s # after -DNACOS.CONNECT.TIMEOUT=2000
Defensive patterns
Strategy: validation
Validate before calling
// Validate before JVM startup — check all property sources
String timeout = System.getProperty("NACOS.CONNECT.TIMEOUT");
if (timeout != null) {
try {
Integer.parseInt(timeout);
} catch (NumberFormatException e) {
throw new IllegalArgumentException(
"NACOS.CONNECT.TIMEOUT must be an integer (milliseconds), got: " + timeout);
}
} Try / catch
// This error occurs during class static initialization and cannot be // caught at the call site — it fails the ParamUtil class load. // Fix the property value before starting the JVM. // No runtime try-catch is effective here.
Prevention
- Set NACOS.CONNECT.TIMEOUT to a plain integer in milliseconds (e.g., 2000).
- Do not include unit suffixes (s, ms) in the property value.
- Audit all property sources (system properties, env vars, nacos-client.properties) for invalid timeout values.
- Remove the property to use the default (1000ms) if unsure of the correct value.
When it happens
Trigger: Setting the system property or environment variable NACOS.CONNECT.TIMEOUT to a non-numeric string (e.g., 'abc', '1s', ''). The default value '1000' is used if the property is absent, so this only fires when an explicit invalid value is provided.
Common situations: Misconfigured JVM system property (-DNACOS.CONNECT.TIMEOUT=2s with a unit suffix); environment variable with a typo or wrong format; a properties file with an incorrect timeout value; copy-paste from documentation that includes units.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- worker Id can't be greater than %d or less than 0, current w
- Illegal Raft system parameters => ReadOnlyOption : [{val}],
- 10000
- PARAMETER_MISSING
- request timeout after {timeout} milliseconds, requestId={req
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/f09f39741debc128.
Report an issue: GitHub.