ERR_HTTP2_PROTOCOL_ERROR When Using Azure FrontDoor CDN

Fredrik Rönnehag 31 Reputation points
2023-09-12T07:44:34.79+00:00

We are using Azure Front Door with CDN active and certain users gets assets timed out. I've tested myself with VPN jumping between locations, it works for me locally but not when I change VPN to a neighbour country.

The origin points to an Azure App Service running NodeJs and Angular. It works for images and static assets but js and css files times out. It seems like they are partially read and then the stream fails?

Here is a logging of the error:

image

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
850 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} vote

Accepted answer
  1. GitaraniSharma-MSFT 50,021 Reputation points Microsoft Employee Moderator
    2023-09-12T12:01:41.0866667+00:00

    Hello @Fredrik Rönnehag ,

    I understand that you have an azure app service and an Azure CDN in front of it and when trying to load the next assets like js and css files, you receive an ERR_HTTP2_PROTOCOL_ERROR.

    You can refer the below thread for more details on how to find the root cause of the issue:

    https://learn.microsoft.com/en-us/answers/questions/1338000/http2-protocol-error-with-azure-cdn

    I requested you to perform a CURL on your origin URL which is resulting in error.

    • In case you receive HTTP 206 in the curl (same as the above thread), then you need to follow the workaround mentioned in the above thread.
    • If you receive HTTP 200, then share the results (masking the origin URL), so that I can investigate further.

    You did a CURL to the origin and received 200 OK, but the results didn't have the details I needed, so requested you to do a CURL again using the below command and reshare the results:

    curl.exe -v -o nul --range "0-8000000" -H "Accept-Encoding: gzip" "https://abcdomain.azureedge.net/assets/index.js"
    

    You came back with an update stating you found the issue as below:

    On the express server you still had a reference to server.use(compression()) and after you removed this, it started working.

    You think it had something to do with the request being sent to accept gzip and br.

    This error is possible if the content is being double compressed, and the browser can't decompress the file.

    If the content is being compressed at the backend and compression is also enabled in the CDN, it is recommended to change it to not compress the files at the backend before serving them.

    There are two ways to enable file compression:

    • Enable compression on your origin server. In this case, Azure CDN passes along the compressed files and delivers them to clients that request them.
    • Enable compression directly on the CDN POP servers (compression on the fly). In this case, the CDN compresses the files and serves them to the end users, even if they don't get compressed by the origin server.

    You shouldn't enable compression on both origin and CDN.

    Refer: https://learn.microsoft.com/en-us/azure/cdn/cdn-improve-performance#compression-rules

    When you disabled all compression on the express server and enabled it in the CDN instead, it started working.

    Kindly let us know if the above helps or you need further assistance on this issue.


    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

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.