socket_connect_timeout

The `wasm_socket_connect_timeout` directive sets a timeout period for establishing socket connections within WebAssembly modules in NGINX.

Syntaxwasm_socket_connect_timeout time;
Defaultnone
Context
Arguments1

Description

The wasm_socket_connect_timeout directive specifies the maximum amount of time allowed for a socket connection to be established when using WebAssembly modules with NGINX. This is particularly relevant when invoking network operations, as establishing a connection can vary in duration depending on external factors like network conditions and server response times. By default, if the connection is not established within the specified timeout period, it will fail, allowing developers to handle connection failures gracefully in their WebAssembly applications.

This directive accepts a time period as its argument. This time can be specified in seconds, minutes, or other time units recognized by NGINX, using typical suffixes like 's' for seconds and 'm' for minutes. The wasm_socket_connect_timeout directive functions at the HTTP server block level, meaning it applies to all WebAssembly operations initiated within that block unless overridden by a more specific configuration elsewhere in the hierarchy. It is crucial to choose an appropriate timeout value based on expected network latency and operational requirements, as setting this value too low could lead to excessive timeout errors under normal conditions, while a very high value might cause your services to hang when connectivity issues occur.

Config Example

http {
    wasm_socket_connect_timeout 60s;
    server {
        listen 9000;
        location / {
            proxy_pass http://backend;
            proxy_wasm my_filter;
        }
    }
}

Ensure the timeout value is appropriate for your network conditions; too low may lead to premature failures, while too high may hang requests.

This directive is applicable only within the context of WebAssembly operations; it does not affect standard NGINX connection timeouts.

If used with other directives affecting timeout behavior, ensure there is no conflict in settings.

← Back to all directives