Detecting JupyterLab Tab Closure Using Traefik v3

Hi!

I’m currently working on a project where I want to detect when a user closes their JupyterLab tab. My thought is to detect the closure of the WebSocket through Traefik v3, and then use that detection to call a stop service function in my Django application.

Here’s a bit more context:

  • There can be multiple JupyterLab servers per user.
  • Each JupyterLab server runs on a Docker Swarm worker node inside a Docker container.
  • These containers are created by a service on a Docker Swarm master.
  • The service itself is created from my Django application using the aiodocker library.

I would greatly appreciate any guidance on how to achieve this as I am new to Traefik, especially with regard to monitoring the WebSocket status through Traefik v3.

Thanks in advance for your help!

You could try to monitor the Traefik access log in JSON format. But I am not sure how you create the 1-to-1 connection between client and container. Usually Traefik load-balances requests between multiple target service containers.

Hi!

Thank you for your reply and suggestion.

I already have a 1-to-1 connection between client and container. I was not asking for it.

I will rely on log monitoring until I find a way for Traefik to directly call a Django function through a URL on detection of the closure of a WebSocket connection.

Unless someone has a better idea?