Replies: 1 comment 3 replies
-
Do you have logs of what happens when Kubernetes attempts to shutdown the container? AIUI Kubernetes issues a Which means you should have |
Beta Was this translation helpful? Give feedback.
-
Do you have logs of what happens when Kubernetes attempts to shutdown the container? AIUI Kubernetes issues a Which means you should have |
Beta Was this translation helpful? Give feedback.
-
We are running an ASGI app using Django Channels in a Kubernetes container environment.
The main issue we’re facing is that when a container is terminated or restarted, WebSocket connections are dropped, but the
closed_at
field of the related channel is not updated. It seems that the consumer’s disconnect() method is not being called properly in these cases.Since our application logic relies on
closed_at
to determine whether a session is still active, this leads to inconsistencies.Of course, we could define a shutdown task to update all closed_at fields when a container stops. However, we don’t know how to distinguish which sessions or channels belong to the specific container being shut down. If there’s a recommended way to identify or tag sessions per container, we’d really appreciate any guidance.
I’m wondering whether this behavior is expected due to limitations in Django Channels or ASGI, or if it can be mitigated by design.
asgi app command
disconnect() example
Thanks in advance! 🙏
Beta Was this translation helpful? Give feedback.
All reactions