[Python] FastAPI WebSocket + Kafka: Only the last connected client receives messages

Discussão em 'Python' iniciado por Stack, Novembro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm building a real-time dashboard using FastAPI WebSockets + Kafka. Everything works perfectly for a single user, but when multiple users connect, only the most recently connected user receives messages.

    The behavior:

    • First user opens dashboard - receives alerts ✓
    • Second user opens dashboard - first user stops receiving, only second user gets messages
    • Second user closes connection - first user suddenly starts receiving again

    It seems like Kafka messages are only going to one WebSocket connection at a time instead of broadcasting to all connected clients.

    Has anyone encountered this? What's the correct way to handle multiple WebSocket clients consuming from the same Kafka topic?

    Continue reading...

Compartilhe esta Página