django-channels 1.x detect when user leaves/refreshes page
there is not perfect way to do this. The main issue is due to TCP the server will not always know that the connection has been dropped until it times out.
however Daphne has 2 options you can configure to help with this --ping-interval and --ping-timeout if you want rapid disconnects then I suggest you set these values to be nice and low.
How can I detect this? Currently I can only do_something if the user clicks a back button and I manually disconnect from the websocket under consideration. Sometimes Websocket DISCONNECT fires, but much of the time it doesn't.
If a user refreshes or leaves a page, the disconnect code cannot run. How can I detect when a user leaves/refreshes?