Django Channels StaticFiles error

Hi good morning in my consumer, when I am calling a websocket endpoint I am getting this error:

Application instance <Task pending name=‘Task-15’ coro=< running at D:\projects\django_5\venv\Lib\site-packages\channels\> wait_for=> for connection <WebSocketProtocol client=[‘’, 52878] path=b’/ws/live-tracker/'> took too long to shut down and was killed.

the thing is I don’t think I am handling any 'staticfiles`, how ever this error comes up in the console.

can please point me to why this ‘messages’ is showing,

for clarification this is my code:

class LiveTracker(AsyncWebsocketConsumer):
    async def connect_to_websocket(self, uri, headers=None):
        async with websockets.connect(uri, extra_headers=headers) as websocket:
            while True:
                message = await websocket.recv()
                if message == "close_connection":
                    await websocket.close()
                await self.send(text_data=message)

    async def connect(self):
        await self.accept()
        session_cookie = await self.fetch_session_cookie()
        headers = {"Cookie": session_cookie}
        uri = "ws://xx.xx.xx.xx:xxxx/api/socket"
        await self.connect_to_websocket(uri, headers)

    async def fetch_session_cookie(self):
        url = 'http://xx.xx.xx.xx:xxxx/api/cookie'
        payload = {
            'email': 'myemail@email',
            'password': 'mypassword'
        headers = {
            'Content-Type': 'application/x-www-form-urlencoded'
        encoded_payload = urllib.parse.urlencode(payload)
        response =, data=encoded_payload, headers=headers)
        session_cookie = response.headers.get('Set-Cookie')
        return session_cookie
    async def disconnect(self, close_code):
         raise StopConsumer()

This is with runserver yes? Likely it’s just an artefact: you get this message when the event loop shuts down before the task has the opportunity to clean up properly.

If you’re able to reduce it to a minimal example, it would be possible to say more.

yes this is with runserver.

I’m sorry this is the most simplified version, the endpoint requires the session cookie (for authentication), without it I cannot test.

so, in a production environment, will this issue persists.


Hi. I am having the same error. Did you solve it?