Friday, January 29, 2021

Django Channels:Detect whether disconnect() was done client or server?

I need to detect whether connection was closed by server or client.How to do it?

disconnect() gets called when client disconnects or server disconnects (using self.close() or by not accept()-ing during connect() ).So I need to detect who caused the disconnect and take action based on that.I tried using custom close codes too.
But if the server disconnects using self.close() or client disconnects abnormally ,then I always get the close_code as 1006.So I cant detect caused the disconnect.
Is there way to do it?

Here's the link to the question in SO with code example.

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment