How to stopconsumer properly

I’m having trouble with my websocket stability and I’m afraid it’s because I’m not shutting down everything before calling StopConsumer(). So, when I raise StopConsumer() in websocket_disconnect() will my async websocket_receive() stop?

Can you be more specific and provide more details about what exactly is happening here?

Note the docs for Closing Consumers:

Once you have finished doing your post-disconnect cleanup, you need to raise channels.exceptions.StopConsumer to halt the ASGI application cleanly and let the server clean it up.

This implies that you raise it after you have finished all of your work related to the disconnect.

However, also note that it’s already raised in websocket_disconnect - are you overriding that function?