Skip to content

Unexpected RealtimeSubscribeStates.TIMED_OUT 10 seconds after subscribe() #1297

@SmaugPool

Description

@SmaugPool

Describe the bug

A subscription status RealtimeSubscribeStates.TIMED_OUT is received 10 seconds after subscribe() call, despite the subscription being still active.

2025-11-04 10:26:16,219 - INFO - Attempting to connect to WebSocket at wss://xxx.supabase.co/realtime/v1/websocket?apikey=sb_secret_xxx
2025-11-04 10:26:16,393 - INFO - WebSocket connection established successfully
2025-11-04 10:26:16,394 - INFO - send: {"event":"phx_join","payload":{"config":{"broadcast":null,"presence":{"key":"","enabled":false},"private":true,"postgres_changes":[]},"access_token":"sb_secret_xxx"},"topic":"realtime:test","ref":"1","join_ref":null}
2025-11-04 10:26:16,394 - INFO - send: {"event":"heartbeat","payload":{},"topic":"phoenix","ref":null,"join_ref":null}
2025-11-04 10:26:16,485 - INFO - receive: '{"ref":"1","event":"phx_reply","payload":{"status":"ok","response":{"postgres_changes":[]}},"topic":"realtime:test"}'
2025-11-04 10:26:16,486 - INFO - parsed message as event=<ChannelEvents.reply: 'phx_reply'> topic='realtime:test' payload=SuccessReplyMessage(status='ok', response=ReplyPostgresChanges(postgres_changes=[])) ref='1'
2025-11-04 10:26:16,486 - INFO - realtime:test : event=<ChannelEvents.reply: 'phx_reply'> topic='realtime:test' payload=SuccessReplyMessage(status='ok', response=ReplyPostgresChanges(postgres_changes=[])) ref='1'

2025-11-04 10:26:16,486 - WARNING - subscription status=RealtimeSubscribeStates.SUBSCRIBED err=None

2025-11-04 10:26:16,486 - INFO - receive: '{"ref":null,"event":"phx_reply","payload":{"status":"ok","response":{}},"topic":"phoenix"}'
2025-11-04 10:26:16,486 - INFO - parsed message as event=<ChannelEvents.reply: 'phx_reply'> topic='phoenix' payload=SuccessReplyMessage(status='ok', response=ReplyPostgresChanges(postgres_changes=None)) ref=None

2025-11-04 10:26:26,396 - WARNING - subscription status=RealtimeSubscribeStates.TIMED_OUT err=None

2025-11-04 10:26:41,396 - INFO - send: {"event":"heartbeat","payload":{},"topic":"phoenix","ref":null,"join_ref":null}
2025-11-04 10:26:41,425 - INFO - receive: '{"ref":null,"event":"phx_reply","payload":{"status":"ok","response":{}},"topic":"phoenix"}'
2025-11-04 10:26:41,425 - INFO - parsed message as event=<ChannelEvents.reply: 'phx_reply'> topic='phoenix' payload=SuccessReplyMessage(status='ok', response=ReplyPostgresChanges(postgres_changes=None)) ref=None

Reproduction

#!/usr/bin/env python3

import os, asyncio, logging
from supabase.client import AsyncClient

logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")

async def main():
    def on_subscribe(status, err):
        logging.warning(f"subscription status={status} err={err}")

    client = AsyncClient(os.environ.get("SUPABASE_URL"), os.environ.get("SUPABASE_KEY"))
    channel = client.channel("test", {"config": {"private": True}})
    await channel.subscribe(on_subscribe)
    while True:
        await asyncio.sleep(1)

asyncio.run(main())

Steps to reproduce

Run the reproduction snippet above.

Library affected

realtime

Library version

supabase 2.22.4

Python version

3.12.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions