wasm_socket_read_timeout
Sets the maximum duration for reading data from a socket in the Wasm context.
Description
The wasm_socket_read_timeout directive is used to specify the maximum time duration that the NGINX server should wait for reading data from a socket before timing out. This is particularly useful in scenarios where WebAssembly (Wasm) modules are executing and waiting for responses from upstream servers or other network resources. By setting this timeout, administrators can control how long the server will attempt to read a response before giving up and potentially aborting the current operation.
The directive accepts a single argument that represents the timeout value, which can be specified in seconds, minutes, or hours (using s, m, or h, respectively). The timeout is applied to each read operation initiated by the Wasm module and serves to safeguard against network stalls or unresponsive upstream services, ensuring that the NGINX instance can efficiently manage resources and maintain responsiveness. When the timeout is reached and no data is read, NGINX will generate an error and handle it according to the server configuration, allowing for potential retries or user notifications.
Config Example
http {
wasm_socket_read_timeout 30s;
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
}Ensure the timeout value is set appropriately to avoid premature timeouts in high-latency environments.
Remember that this directive only applies to Wasm context and is different from the standard NGINX read timeout settings.