Sometimes getting error 502 "Unexpected EOF at target"

In one of our proxies was noticed error response (502 Bad Gateway):

{
   "fault":{
      "faultstring":"Unexpected EOF at target",
         "detail":{
            "errorcode":"messaging.adaptors.http.flow.UnexpectedEOFAtTarget"
          }
      }
}

This error is returned randomly, most of the time we receive correct response.

I already checked a similar questions here and reviewed the Apigee doc regarding this issue https://docs.apigee.com/api-platform/troubleshoot/runtime/502-bad-gateway

Seems that it is not an backend issue, when to use direct URL response is always valid.

And SSL configuration is already enabled:

 <HTTPTargetConnection>
	<SSLInfo>    
		<Enabled>true</Enabled>
	</SSLInfo>
 </HTTPTargetConnection>

Any thoughts what the reason can be?

0 4 3,717
4 REPLIES 4

Backend services can sometimes close connections (and therefore generating the 502 error on Apigee side) when under heavy load. Use API Monitoring to see if there's any correlation between 502 errors and increased traffic etc. If that's the case, you may need to add traffic management policies such as SpikeArrest to prevent flooding the backend service.

thank you for an advice, but we already use SpikeArrest policy:

<SpikeArrest async="false" continueOnError="false" enabled="true" name="Spike-Arrest">
    <DisplayName>Spike Arrest</DisplayName>
    <Properties/>
    <Identifier ref="request.header.apikey"/>
    <Rate>100ps</Rate>
</SpikeArrest><br>

Do you know if your backend can handle the rate set in your spike arrest policy?

Have you looked for a correlation between traffic and errors as was suggested? If yes, do you know if the error is associated with a particular request

Hi Team,

i have also noticed that in the MP system.log we see below error

NIOThread@14 ERROR HTTP.CLIENT - HTTPClient$Context$3.onException() : SSLClientChannel[Connected: Remote:XX:443 Local:XX:37752]@1434278 useCount=9 bytesRead=0 bytesWritten=415 age=105363ms lastIO=266ms isOpen=true.onExceptionRead exception: {} java.io.EOFException: eof unexpected

If we want to analyse this further, then we need to know what are these paremteres

useCount=9 bytesRead=0 bytesWritten=415 age=105363ms lastIO=266ms

LastIO is basically the time taken by current request ie apigee received response of eof after 266ms.

Any idea what does the rest of the variable means?
does userCount means number of current thread connected to the target?