I am facing a persistent 502 Bad Gateway error in Apigee with the fault:
Unexpected EOF at target
errorcode: messaging.adaptors.http.flow.UnexpectedEOFAtTarget
reason: TARGET_READ_UNEXPECTED_EOF
This happens when calling a backend API that takes ~4 minutes to respond.
The failure is consistent and occurs at approximately ~60 seconds, even though all timeouts have been increased at the Apigee TargetEndpoint and the backend Load Balancer.
Architecture
-
Apigee: (X)
-
Connectivity: Apigee → PSC (Private Service Connect) → Internal Application Load Balancer
-
Backend: Rest API
-
Protocol: HTTPS
-
Method: GET
-
Backend response time: ~4 to 5 minutes
-
LB backend-service timeout: 1800000 ms (30 minutes)
Observed Behavior
-
Request fails with 502 Bad Gateway
-
Apigee trace shows:
TARGET_READ_UNEXPECTED_EOF Unexpected EOF at target -
Postman shows:
-
Status:
502 -
Failure time: ~60 seconds
-
-
Backend does not return any headers/body before the connection is closed
TargetEndpoint Configuration
<TargetEndpoint name="default">
<HTTPTargetConnection>
<URL>{targeturl}</URL>
<Properties>
<Property name="chunked.enabled">true</Property>
<Property name="request.streaming.enabled">true</Property>
<Property name="response.streaming.enabled">true</Property>
<Property name="connect.timeout.millis">1800000</Property>
<Property name="io.timeout.millis">1800000</Property>
<Property name="api.timeout">1800000</Property>
<Property name="keepalive.timeout.millis">30000</Property>
</Properties>
<SSLInfo>
<Enabled>true</Enabled>
<IgnoreValidationErrors>true</IgnoreValidationErrors>
</SSLInfo>
</HTTPTargetConnection>
</TargetEndpoint>
What I Have Already Tried
-
Increased Apigee TargetEndpoint timeouts
-
Increased Internal LB backend-service timeout to 30 minutes
-
Reduced
keepalive.timeout.millisto avoid stale connection reuse -
Enabled request/response streaming
-
Verified HTTPS hostname (not IP)
-
Tested via Postman and browser (same result)
Despite all this, the request always fails around ~60 seconds with EOF.