Loading

Mule Application Experiences a Connection Timeout After TCP Handshake When Using Streaming

Publiseringsdato: Sep 2, 2025
Beskrivelse

Symptom

A connection timeout error occurs when attempting to make an outbound request (e.g., via an HTTP Requestor) from a Mule application. This error can manifest in several ways:

  • A remote server-side error, such as Remotely closed.
  • A local connector error, such as java.net.ConnectException: Connect timeout.

The underlying behavior observed at the network level is that the three-way TCP handshake completes successfully, but the client application (Mule) fails to send the next expected data packet, such as the ClientHello to initiate the TLS handshake. Due to this delay, the remote server or an intermediary network device closes the idle connection, resulting in a timeout.

This issue is most common when processing large payloads.

 

Cause

The primary cause of this delay is the use of deferred execution in a DataWeave transformation (deferred=true) immediately before the connector making the network call (e.g., HTTP Requestor).

When deferred=true is used, the execution of the DataWeave script is postponed until the payload is actively consumed by the subsequent component. The process is as follows:

  1. The HTTP Requestor component begins its execution and establishes the TCP connection with the target endpoint.
  2. Once the connection is established, the Requestor attempts to send the request data (including the TLS handshake, if applicable).
  3. At this point, the Requestor requests the payload from the preceding component (the DataWeave transformation).
  4. Only then does the DataWeave script begin to execute to generate the payload. If the payload is large or the transformation is complex, this process can take a considerable amount of time.

This latency between the TCP connection establishment and the sending of the first application data bytes can exceed the remote server's timeout threshold, causing it to close the connection prematurely.

Løsning

Solution

There are two main solutions to resolve this issue. The choice depends on your application's requirements and memory handling capabilities.

Option 1: Disable Deferred Execution in DataWeave

This forces the DataWeave transformation to complete before the HTTP Requestor begins its execution. This ensures the payload is fully ready at the moment the connection is established.

  • In your Transform Message component, change the deferred setting from true to false.
Option 2: Disable Streaming in the HTTP Requestor

Configure the HTTP Requestor to not use streaming transfer mode. This causes the connector to wait for the entire payload to become available and load it into memory before sending the request. Like the first option, this resolves the latency.

  • In the configuration of the HTTP Requestor component, set the Streaming strategy to NEVER.

Related Information

  • Memory Impact: Second solution can increase the application's memory consumption, as the entire payload will be loaded into memory instead of being processed as a stream. This is an important consideration when handling very large files or data sets.
  • Monitoring: After applying either of these solutions, it is recommended to monitor the application's performance and memory usage to ensure there are no adverse impacts.
Knowledge-artikkelnummer

005135165

 
Laster
Salesforce Help | Article