wasm_socket_connect_timeout

Sets the timeout for establishing WebAssembly socket connections in NGINX.

Syntaxwasm_socket_connect_timeout time;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The wasm_socket_connect_timeout directive specifies the maximum time to wait for a WebAssembly (Wasm) socket connection to establish in NGINX when using the Proxy-Wasm feature. This directive is applicable within the http, server, and location contexts, allowing for flexible configuration in various parts of the server configuration. The timeout can prevent hanging connections by enforcing a limit, making it particularly useful in high-traffic scenarios or when dealing with slow network conditions.

The parameter for this directive is a time value which can be specified in seconds or a time format like 60s, 1m, etc. When the specified timeout period is reached without establishing a connection, an error is raised, allowing the NGINX server to proceed with its operations without being indefinitely stalled. This is crucial for maintaining service responsiveness, especially when utilizing WebAssembly modules for functionality like API gateways or edge processing.

You can also set different timeout values depending on the expected performance of your application and the characteristics of the operations you intend to perform through WebAssembly. Adjusting this directive can help balance between responsiveness and the actual connection latency experienced due to network conditions.

Config Example

wasm {
    module my_filter /path/to/filter.wasm;
}

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

Ensure that the timeout value is appropriate for your application's connection expectations; too short may cause connection errors.

Using overly long timeout values can lead to degraded user experience due to slow responses.

← Back to all directives