alibaba/nacos · critical · IllegalArgumentException

[http-client] invalid read timeout:{}

Error message

[http-client] invalid read timeout:{}

What it means

Thrown by ParamUtil.initReadTimeout() during static class initialization when the NACOS.READ.TIMEOUT property cannot be parsed as an integer via Integer.parseInt. The default value is "3000" (ms), so this only fires when an explicit override is non-numeric. Because it runs in a static initializer block (line 56), the exception propagates as ExceptionInInitializerError and prevents the entire ParamUtil class — and therefore the Nacos client — from loading.

Source

Thrown at client/src/main/java/com/alibaba/nacos/client/utils/ParamUtil.java:85

                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 {
            return Double.parseDouble(
                NacosClientProperties.PROTOTYPE.getProperty(PER_TASK_CONFIG_SIZE_KEY,
                    DEFAULT_PER_TASK_CONFIG_SIZE_KEY));
        } catch (NumberFormatException e) {
            LOGGER.error("[PER_TASK_CONFIG_SIZE] PER_TASK_CONFIG_SIZE invalid", e);
            throw new IllegalArgumentException(
                "invalid PER_TASK_CONFIG_SIZE, expected value type double", e);
        }
    }
    
    public static int getConnectTimeout() {
        return connectTimeout;
    }

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Check the full stack trace for ExceptionInInitializerError wrapping this IllegalArgumentException — the offending value is in the message.
  2. Inspect all configured sources of NACOS.READ.TIMEOUT: JVM -D flags, environment variables, nacos-client.properties files, and any NacosClientProperties.setProperty calls.
  3. Change the value to a plain integer in milliseconds (e.g. 3000); remove unit suffixes like 'ms' or 's'.
  4. If a Duration-style value is desired upstream, convert it to milliseconds before passing it into NacosClientProperties.

Example fix

// before
System.setProperty("NACOS.READ.TIMEOUT", "3000ms");

// after
System.setProperty("NACOS.READ.TIMEOUT", "3000");
Defensive patterns

Strategy: validation

Validate before calling

String rawTimeout = System.getProperty("NACOS.READ.TIMEOUT", "3000");
try {
    Integer.parseInt(rawTimeout);
} catch (NumberFormatException e) {
    throw new IllegalStateException("NACOS.READ.TIMEOUT must be an integer, got: " + rawTimeout, e);
}

Prevention

When it happens

Trigger: Setting -DNACOS.READ.TIMEOUT=abc or a JVM system property / environment variable with a non-integer value (e.g. "3s", "3,000", empty string with whitespace). Also triggered by passing Properties containing NACOS.READ.TIMEOUT with a garbage value to NacosClientProperties.

Common situations: Operators copy-paste a timeout like "3000ms" instead of "3000"; YAML files inject quotes that produce non-numeric strings; CI pipelines set environment variables with units appended; migration from Spring property sources where unit-suffixed Duration values (e.g. "3s") leak into the Nacos property namespace.

Understand the failure class

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/6d96ca7c738eeb42. Report an issue: GitHub.