Search code examples
asp.net-coreopenshiftocelot

Timeout error for requests that take longer than 30 secs


We have an application that consists of some microservices (asp.net core 5.0 web API applications) and a gateway (Ocelot). Everything is configured nicely (CORS) and working fine. Except for a request that takes more than 30 seconds. We know Ocelot's default timeout is 90 seconds and there is no QoS policy that lowers that value. And that 90 seconds is valid in my development machine (Windows 10). I can make requests that take more than 30 seconds in my development environment. I checked the logs at the gateway and the microservices they indeed succeed like below :

Gateway log

[19:48:36 INF] Request finished HTTP/1.1 POST http://gatewaydomain/api/crm/v1/portfolio/getActivityCockpitView  application/json;charset=UTF-8 332 - 200 13082 application/json;+charset=utf-8 47560.9299ms

API log

[19:48:36 INF] Request finished HTTP/1.1 POST http://apidomain/api/v1/portfolio/getActivityCockpitView  application/json;charset=UTF-8 332 - 200 - application/json;+charset=utf-8 47554.2577ms

And also I'm sure it's not related to the client request config my Axios instance is configured as :

const service = axios.create({
  timeout: 1000000, // request timeout
  maxContentLength: 200000

})

I also tried to disable the chrome security settings (to see if it is related to the client-side) described in this so answer and it didn't work.

Our application deployed in an OpenShift cluster we use standard asp.net 5.0 containers ( mcr.microsoft.com/dotnet/aspnet)

And we don't have any WAF in front of the gateway (yet :) ) that might fiddle our requests.

I would be grateful for any idea about what might go wrong.

Edit :

Also managed to get a timeout with the same request with the postman. So it seems it's not a CORS issue but still has no idea what is causing the timeout.


Solution

  • Yes, I finally found it before I lose more hair :)

    It turned out Openshift Routes has default 30-sec timeouts. If you want to extend that value you need to edit your routes yaml file like below :

     - kind: Route
        apiVersion: v1
        id: "$APPLICATION_NAME-rhdmcentr-http"
        metadata:
          name: "$APPLICATION_NAME-rhdmcentr"
          labels:
            application: "$APPLICATION_NAME"
          annotations:
            haproxy.router.openshift.io/timeout: 90s
    

    Taken from the documentation.