Server-sent events and Azure Application Gateway for Containers

Timo Notheisen 20 Reputation points
2025-02-03T08:43:50.6766667+00:00

I have a server that supports server-sent events. When running this server locally, everything works as expected.

But as soon as I deploy it in an AKS Kubernetes cluster in front of an Azure Application Gateway for Containers, the SSE connection times out after 60 seconds. After some research, I found the following documentation: https://learn.microsoft.com/en-us/azure/application-gateway/for-containers/server-sent-events?tabs=server-sent-events-gateway-api. There it's stated that you should create a RoutePolicy and configure a timeout of 0s. But doing so doesn't change anything. The observed timeout remains 60s.

I then played around with the RoutePolicy a bit. And in case the timeout is higher than 0s and lower than 300s, the RoutePolicy works. But (as mentioned above) 0s doesn't seem to do anything at all. And any value greater than 300s leads to a 300s timeout. So the 300s appears to be the maximum.

Kubernetes version: 1.29.11.

alb-controller Helm Chart version: 1.3.7

I created a minimal example, which you can find on GitHub: https://github.com/tnotheis/SseServerTest

You can run the SSE server locally with the following command:

dotnet run dotnet run -p .\SseServerTest\SseServerTest.csproj

Afterwards, open http://localhost:5293/sse in your browser. You will receive 1 event per second, which makes it easy to see after which time a timeout occurs.

You will notice that, when running it locally, there will never be a timeout.

I further added a kubernetes.yaml file, which contains all Kubernetes resources necessary to deploy the application into a cluster with an already existing Azure Application Gateway for Containers. Just make sure to replace the name of the gateway resource as well as the hostname (both places are marked with TODO comments).

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,293 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Akshay kumar Mandha 2,665 Reputation points Microsoft External Staff
    2025-02-04T22:03:00.6666667+00:00

    Hi Timo Notheisen,
    Thank you for your reply.
    I understand your latest comment. Regardless of the timeout settings, it always times out after 60 seconds. If that is the case, This suggests that the timeout might be overridden, possibly due to an older configuration with a default timeout of 60 seconds in the Ingress. Could you please check the configuration for any default settings that might be causing this issue? Let me know if you find any configuration conflicts

    Additionally, as you mentioned that it works locally but encounters issues when deployed in AKS, could you please provide some information on how you set up the SSE locally? It would be helpful to get an overview of the overall setup and the steps you followed for both the local environment and the AKS deployment. This will allow us to identify any potential configuration conflicts or differences


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.