socket_send_timeout
The `wasm_socket_send_timeout` directive sets the maximum time for sending data over a WebAssembly socket in NGINX.
Description
The wasm_socket_send_timeout directive defines a timeout duration for sending data through a WebAssembly socket. This directive is particularly relevant in environments where NGINX is extended with WebAssembly capabilities, enabling additional control over how long the socket operations can block before timing out. The primary utility of this directive lies in optimizing the performance of applications running in NGINX with embedded WebAssembly modules by preventing them from being stuck indefinitely during send operations due to network issues or unresponsive peers.
The directive accepts a single argument, which is the timeout duration specified in seconds or in a format compatible with NGINX’s time directives (e.g., 60s, 1m, etc.). When the specified duration is exceeded, the connection will be terminated, and an error will be returned. This is crucial for maintaining the robustness of applications that rely on real-time data transfer, as it ensures that the application does not hold up resources longer than necessary.
When configuring this directive, it is essential to choose a value that balances performance and reliability. Setting the timeout too low might lead to frequent disconnections, while setting it too high could cause resources to be tied up longer than desired during socket send operations.
Config Example
wasm {
module my_filter /path/to/filter.wasm;
}
http {
server {
listen 9000;
location / {
proxy_wasm my_filter;
proxy_pass http://backend;
}
}
wasm_socket_send_timeout 30s;
}Ensure that the timeout value is appropriate for your application's performance needs.
Be aware of the potential for increased connection errors if the timeout is set too low.