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=<StaticFilesWrapper.call() running at D:\projects\django_5\venv\Lib\site-packages\channels\staticfiles.py:44> wait_for=> for connection <WebSocketProtocol client=[‘127.0.0.1’, 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()
break
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 = requests.post(url, data=encoded_payload, headers=headers)
session_cookie = response.headers.get('Set-Cookie')
return session_cookie
async def disconnect(self, close_code):
raise StopConsumer()