Client not receiveing response from Application Gateway timing out and collecting 400 httpStatus

Matteo Mario Cossu 21 Reputation points
2024-10-14T13:05:30.3033333+00:00

I have a NodeJS Express API.
It exposes an endpoint expecting a multipart form to collect files.
It is deployed in an AKS instance.
The AKS is behind an Application Gateway.

A client is performing several serial calls toward the endpoint described above.
At some point, at POST request N of M, where N < M, it stops receiving an answer, simply timing out.
There's no pattern in the failing requests.
The application gateway logs (AzureDiagnostics table) display a record with dimension 'httpStatus_d' valued 400 and no 'serverStatus_s' dimension.
The API logs display no request, meaning the request is not being forwarded by the application gateway.

I removed the WAF_v2 and redeployed the AGW as a Standard_v2 tier (no waf, so no policies should block the request at this point) and still experiencing the issue.

I need to:

  • understand what's causing the timeout / 400 issue
  • find a solution for the issue

MMC

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,080 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,145 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 12,011 Reputation points
    2024-10-14T20:04:08.09+00:00

    Hello

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    Regarding your explanation:

    You can adjust the maxRequestBodySize on your Application Gateway to handle larger file uploads using Azure CLI, for example - https://learn.microsoft.com/en-us/azure/application-gateway/configuration-overview#http-settings:

      az network application-gateway http-settings update \
          --gateway-name myAppGateway \
          --resource-group myResourceGroup \
          --name appGatewayBackendHttpSettings \
          --max-request-body-size 10485760 # For 10MB
    

    Also, make sure that both the client request timeout and the backend timeout settings on the AGW are long enough to accommodate the upload, the example shows Azure CLI bash command:

        az network application-gateway http-settings update \
          --gateway-name myAppGateway \
          --resource-group myResourceGroup \
          --name appGatewayBackendHttpSettings \
          --timeout 180 # Increase to 3 minutes, or adjust as needed
    

    Other things you can do is to check Logs for Patterns, Check NodeJS API Scaling, and check Client-Side Request Behavior to handle multiple and serial request. https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-troubleshooting-502?source=recommendations

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


  2. KapilAnanth-MSFT 46,956 Reputation points Microsoft Employee
    2024-10-15T11:11:44.43+00:00

    @Matteo Mario Cossu ,

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    I see you have checked the Access log.

    • For the field "serverStatus"
    • May I ask what is the value in the field "serverRouted"
    • This will confirm if the App gateway did forward the request to backend or not.

    Also,

    • Note that "400 – Bad Request" is sent as a response when a request isn't compliant to RFC.
    • See : 4XX response codes (client error)
      • You can see a huge list of reasons as to why 400 response is received.
    • Can you please confirm if the "N" number of requests are actually proper HTTP/HTTPS request and there is no conflict with the above mentioned reasons?

    Do you perform file upload operations?

    Cheers,

    Kapil


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.