2

My application is running Node.js v12.22.1 with Express, MongoDB and Vue.js. An Apigee server is serving as a gateway between the backend and the client.

If a request takes more than 2 minutes to complete (which can happen if the backend calls another backend service, that does some long calculations), it yields 502 Bad Gateway on the front-end. This problem occurs exactly 2 minutes into the request, so I assume the timeout is the problem. In my version of node, the default timeout is 2 minutes.

The 502 error is not logged anywhere on the backend. The backend actually fulfills the request and logs a 200 Ok in about 4 minutes (but the client have already received an error at this point).

Error body:

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

This error is described in the Apigee docs, which leads me to believe that the intermediate Apigee server is the source of this error.

I've used the timeout middleware to increase request timeout to 10 minutes. The server now responds with 503 if the inbound request exceeds the timeout. This solves the problem, but there are still things I don't quite understand.

The question: If I configure the timeout on the backend, how come the error is thrown by Apigee, not by the backend itself? Let's omit the possibility of a logging problem and assume logging is fine.

P.S. I've also raised keep-alive on the backend as suggested by the Apigee docs. It had no effect on the problem.

P.P.S I understand that having requests that take 2+ minutes is not ideal, but that's what I'm stuck with for now.

DIRECTcut
  • 140
  • 9

0 Answers0