Issue
A REST Call activity is configured with a timeout of, for instance, 10 seconds in Mendix.
Different timeout behavior is observed depending on the failure scenario:
Scenario 1 – Connection Timeout
When a connection to the target server cannot be established, the request fails after approximately 10 seconds, which matches the configured timeout.
Example error:
java.net.SocketTimeoutException: Connect timed out
Caused by:
org.apache.http.conn.ConnectTimeoutException:
Connect to <host>:443 failed: Connect timed out
Scenario 2 – Read Timeout
When a connection to the target server is successfully established, but no response is returned within the configured timeout, the request does not fail after 10 seconds. Instead, the request fails after approximately 20 seconds.
Example error:
java.net.SocketTimeoutException: Read timed out
Caused by:
java.security.PrivilegedActionException:
java.net.SocketTimeoutException: Read timed outAs a result, it may appear that the configured timeout is not being honored for read timeout scenarios.
Environment
Studio Pro (all versions)
Cause
This behavior is caused by the difference between a connection timeout and a read (socket) timeout.
A connection timeout is applied during the TCP connection establishment phase. If the connection cannot be established within the configured timeout period, the request is terminated immediately, and a connection timeout exception is raised. This explains why the observed duration is approximately equal to the configured 10-second timeout.
A read timeout is applied after the connection has already been established. The timeout is enforced while data is being read from the socket and represents the maximum period of inactivity during read operations, rather than the total duration of the HTTP request.
Because multiple read operations may occur during response processing (for example, while receiving response headers and response content), the total elapsed time experienced by the application may exceed the configured timeout value. Consequently, a read timeout configured for 10 seconds may be observed as an overall request duration of approximately 20 seconds before a SocketTimeoutException: Read timed out exception is reported.
Therefore, the configured timeout should not be interpreted as a guaranteed maximum execution time for the entire REST request when a read timeout scenario occurs.
Solution / Workaround
No configuration issue is present when the described behavior is observed.
The timeout configured in the Mendix REST Call activity is correctly applied; however, read timeouts are handled differently from connection timeouts by the underlying HTTP client implementation. As a result, the total elapsed request duration may exceed the configured timeout value in read timeout scenarios.
Internal information related
- 282408
Additional information
Not Applicable
0 Comments