Support for Socket Write and Read Timeout Settings in CRT #695
Labels
feature-request
A feature should be added or improved.
needs-triage
This issue or PR still needs to be triaged.
Describe the feature
The current implementation of the CRT's SocketOptions does not provide support for configuring read and write timeouts for non-blocking socket operations. While traditional blocking sockets can leverage options like SO_RCVTIMEO (receive timeout) and SO_SNDTIMEO (send timeout) to set timeouts for read and write operations, CRT operates in a non-blocking mode, requiring custom mechanisms to achieve similar timeout behavior.
Use Case
We are migrating our Java SDK clients to the CRT-based HTTP client. The existing SDK supports configurable socket-level timeouts that ensure timely error handling and retries if:
To maintain compatibility and ensure robust error handling in non-blocking CRT, we need equivalent timeout settings that close the connection when timeouts are exceeded.
Proposed Solution
Add the following properties to SocketOptions to support timeout settings:
readTimeoutMs
: The maximum time (in milliseconds) allowed to complete a read operation.writeTimeoutMs
: The maximum time (in milliseconds) allowed to complete a write operation.Implement dedicated read timeout handlers and write timeout handlers that monitor the progress of non-blocking operations.
These handlers should enforce timeouts:
Read Timeout Handler: Monitors the time elapsed since a read operation is triggered. If no data is received within the readTimeoutMs, raise a timeout exception.
Write Timeout Handler: Monitors the time elapsed since the last write operation. If data cannot be sent within the writeTimeoutMs, raise a timeout exception.
Other Information
No response
Acknowledgements
The text was updated successfully, but these errors were encountered: