Websocket timed out waiting for pong

sanic=22.6.2 python3.8


[2023-02-08 14:13:17][impl.py:236][WARNING]:Websocket timed out waiting for pong
[2023-02-08 14:13:19][server.py:172][INFO]:connection open
async def ws_send(request: Request, ws):
    col = DB.get_col()
    while True:
        data = []
        async for item in col.find():
            item = format_item(item)
        data = json.dumps(data)
        await ws.send(data)
        await asyncio.sleep(2)

vue client

setup() {
    const ws_url = import.meta.env.VITE_WS_URL
    const {status, data, send, open, close} = useWebSocket(ws_url, {autoReconnect: true})

    const state = reactive({
      lists: []

    watchEffect(() => {
      state.lists = JSON.parse(data.value)

    onMounted(() => {
      state.lists = []
    return state

The warning comes prior to the connection being opened - not sure why, but is your function working otherwise?

There are many connection opened logs before warning

I want to know why the connection is disconnected

There’s not enough information here to answer your question.

Websocket timed out waiting for pong

That is why. Looks like a problem with your WS client. Sanic tried sending a ping and did not receive back a pong. This is a standard WS protocol interaction that the client should understand and respond to.