How to kill a disconnected websocket?

21 views
Skip to first unread message

Shin Yeung

unread,
Oct 23, 2019, 10:55:52 PM10/23/19
to Django users
Hi,
    I'm trying to write a Message Subscription, so I did these:
    1. choose Channels and it''s WebsocketConsumer as my websocket-server
    2. write a while loop, querying my message center every second
    3. running the loop after websocket connected

    and I find that:
    1. I can't send a message because of the loop still running
    2. daphne received the DISCONNECT signal, but the connection didn't close(still output something in loop)

    so I want to know if I could:
    1. kill DISCONNECTED websocket
    or 2. get websocket status, so I can break the loop when status change
    or 3. receive message inside the loop

    I've found the dwebsocket which can receive message manually, but I prefer to use channels.

    Many thanks if anyone can give me some suggestions!
Reply all
Reply to author
Forward
0 new messages