Intermittent request failure when using YARP Proxy (Downstream Service Responds in Milliseconds)

56 views Asked by At

I'm encountering intermittent HTTP request failures with status code 0 while using YARP for proxying.

Logs show that YARP successfully forwards the request and downstream service receives and responds to the request within milliseconds with a 200 status code (success). However, the YARP logs show the request finished with status code 0 after a significant delay (around 40 seconds in this case).

YARP logs:

2024-03-27T14:27:55.2109958+05:00 [INF] (Microsoft.AspNetCore.Hosting.Diagnostics) Request starting HTTP/1.1 POST http://proxy.geekabyte.com.au/api?vendor=vendor1&msisdn=92XXXXXXXX application/xml 470
2024-03-27T14:27:55.2116887+05:00 [INF] (Yarp.ReverseProxy.Forwarder.HttpForwarder) Proxying to "http://api.geekabyte.com.au/ws?vendor=vendor1&msisdn=92XXXXXXXX" "HTTP/2" "RequestVersionOrLower" "no-streaming"
2024-03-27T14:28:35.2132571+05:00 [INF] (Microsoft.AspNetCore.Hosting.Diagnostics) Request finished HTTP/1.1 POST http://proxy.geekabyte.com.au/api?vendor=vendor1&msisdn=92XXXXXXXX application/xml 470 - 0 - - 40002.2840ms

Downstream service logs:

2024-03-27T14:47:26.3506452+05:00 [INF] (Microsoft.AspNetCore.Hosting.Diagnostics) Request starting HTTP/1.1 POST http://api.geekabyte.com.au/ws?vendor=vendor1&msisdn=92XXXXXXXX application/xml 470
...
....
...
2024-03-27T14:47:26.6469643+05:00 [INF] (Microsoft.AspNetCore.Hosting.Diagnostics) Request finished HTTP/1.1 POST http://api.geekabyte.com.au/ws?vendor=vendor1&msisdn=92XXXXXXXX application/xml 470 - 200 1034 application/xml 296.3219ms

Below is the YARP proxy config, which is pretty standard one:

"ReverseProxy": {
  "Routes": {
    "locationServiceRoute": {
      "ClusterId": "locationServiceProvider",
      "AuthorizationPolicy": "invokeLocationServicePolicy",
      "Match": {
        "Path": "/api",
        "Methods": [ "POST" ]
      },
      "Transforms": [
        {
          "PathRemovePrefix": "/api"
        }
      ]
    }
  },
  "Clusters": {
    "locationServiceProvider": {
      "Destinations": {
        "destination1": {
          "Address": "http://api.geekabyte.com.au/ws"
        }
      }
    }
  }
}
0

There are 0 answers