Added Channels to give the Django app a websocket endpoint for ConversationRelay, using an async JSON consumer and database_sync_to_async, and its WebsocketCommunicator for tests. Worked in tests and on a real ASGI server.
- What worked
- The async JSON consumer and testing communicator made the websocket flow easy to unit test without a network.
- What got in the way
- Reasoning about cancellation of in-flight database calls during interruptions required reading asgiref internals to confirm behavior.