← Proxy | Timeouts (中文) | Retries →
Default
timeout— 30000ms (30 seconds)
Set via httpOptions.timeout when creating the client. This becomes the default timeout for all requests.
const client = new ECSClient({
region: "cn-beijing",
httpOptions: {
timeout: 5000,
},
});Specify timeout for a single request via options.timeout when calling send. This overrides the client-level setting.
await client.send(slowCommand, { timeout: 30000 });For more fine-grained control:
connectTimeout: TCP connection timeout (milliseconds). Implemented by overriding the Agent'screateConnectionmethod with a custom timer on the socket — covers only the TCP handshake phase (not TLS handshake). If TLS negotiation stalls,readTimeoutwill act as a fallback.readTimeout: Overall request-response timeout (milliseconds). Maps to the axiostimeout, covering the entire lifecycle from request sent to response received.
When readTimeout is not set, it falls back to timeout for backward compatibility.
const client = new ECSClient({
region: "cn-beijing",
httpOptions: {
connectTimeout: 3000,
readTimeout: 30000,
},
});Note: If both
readTimeoutandtimeoutare specified,readTimeouttakes precedence.connectTimeoutindependently controls the initial connection phase.