Hello @Jan Baggen Thanks for reaching Microsoft Q&A, I'm @Akila G from Azure Networking POD Team,
Issue - When using Application Gateway WAF V2 with HTTP/2 enabled, requests for JavaScript "chunk-*.js" files intermittently fail with net::ERR_CONNECTION_CLOSED. Disabling HTTP/2 resolves the issue, allowing the requests to succeed via HTTP/1.1. The problem is isolated to chunked JavaScript files, and retrying the failed requests usually works.
Solution - Header Size Limitations and Request Failures in HTTP/2
In certain scenarios, especially within enterprise environments, the size of HTTP request headers can grow significantly due to factors such as increased user group memberships and the use of large cookies for session management.
When the total size of the HTTP headers exceeds the server's configured limits, the request may be rejected, resulting in error responses such as HTTP 400 (Bad Request) or HTTP 431 (Request Header Fields Too Large).
This issue is particularly relevant in HTTP/2, which enforces a default maximum header size limit of 16 KB (16,384 bytes). A common contributor to exceeding this limit is an excessively large Cookie header, often caused by:
• Multiple cookies with large values (e.g., encoded JWT tokens),
• Applications storing too much user or session data in cookies,
• Users being assigned to a high number of security groups, which can inflate token or header size when identity information is included in requests.
To prevent these errors, it's important to:
• Optimize the use of cookies by storing only essential data,
• Consider server-side session storage to minimize header bloat,
• Reduce the number or size of headers sent with each request,
• Or, where appropriate and secure, increase the server’s header size limit.
By addressing these factors, organizations can ensure better reliability and performance in applications operating over HTTP/2.
Please click Accept Answer and upvote if the above was helpful.
Thanks.
@Akila G