Multi-tenant Django application with 100's of WebSockets using Daphne/Channels. channels==2.4.0 channels-redis==2.4.2 daphne==2.5.0 Django==2.2.13
Only clue I have at this point is WebClients seem to hang up waiting for messages that are not delivered. I see in the Django logs "RuntimeError: Lock is not acquired." over and over throughout the day. Sample client code I have here causes the issue at will. I can only hit it with 20 or so tasks before it falls over. import time async def test_socket(n, url, count, delay): uri = 'wss://{0}/ws/'.format(url) print('Starting task {0}...'.format(n)) async with websockets.connect(uri, close_timeout=5, ping_interval=5, ping_timeout=5) as websocket: payload = '{"stream":"ping", "payload":{}}' for i in range(0, count): print('TASK {0} : Channels/daphne request {1} times'.format(n, i)) await websocket.send(payload) asyncio.sleep(delay) response = await asyncio.wait_for(websocket.recv(), timeout=30) print('TASK {0} : Channels/daphne for responded {1} {2} times'.format(n, i, response)) async def start_tasks(loop, url, count, delay, tasks): t = [test_socket(n, url, count, delay) for n in range (0, tasks)] await asyncio.gather(*t, loop=loop) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--url', type=str, help='url to hit') parser.add_argument('--count', type=int, default=1, help='number of iterations') parser.add_argument('--delay', type=int, default=1, help='delay in 10ths of a second') parser.add_argument('--tasks', type=int, default=1, help='number of tasks') args = parser.parse_args() loop = asyncio.get_event_loop() try: result = loop.run_until_complete(start_tasks(loop, args.url, args.count, args.delay, args.tasks)) except Exception as ex: print(ex) -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2f4ca94f-a687-4b07-855e-e5ae8ec52b0dn%40googlegroups.com.