Drain inbound WebSocket queues after a clean outbound close
Drain inbound WebSocket queues after a clean outbound close
In a full-duplex WebSocket consumer, a clean outbound send failure does not prove the inbound queue is empty. Cancelling the reader when a microphone sender finishes, or aborting it after a benign playback-ACK write failure, can discard queued audio and terminal markers. Preserve a bounded inbound drain for clean closure, including paced callbacks, and continue consuming already queued messages when ACK writes are no longer possible. Keep abnormal transport, protocol and callback failures visible, and keep explicit cancellation prompt. Record only received audio and markers; a separate server trace cannot repair missing client delivery evidence.
Applies when: a WebSocket carries paced media and client acknowledgements concurrently. Keywords: WebSocket asyncio full duplex close drain audio queue playback acknowledgement