© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•6mo ago•
3 replies
motivated

python realtime silent timeout issue

I have a long-running, asynchronous Python service (using
asyncio
asyncio
) that runs inside a Docker container. Its primary job is to listen for database changes.

Implementation:
My implementation follows this pattern:

1. On service startup, I create a single, global
AsyncClient
AsyncClient
instance using
await acreate_client(...)
await acreate_client(...)
.
2. I then immediately subscribe to
INSERT
INSERT
and
UPDATE
UPDATE
events on a specific table using the Realtime client:
    # In my main async function:
    supabase_channel = supabase.realtime.channel("my_table_changes")
    await (
        supabase_channel
            .on_postgres_changes(event="INSERT", ..., callback=my_async_insert_handler)
            .on_postgres_changes(event="UPDATE", ..., callback=my_async_update_handler)
            .subscribe()
    )
    # The service then waits indefinitely on an asyncio.Event for a shutdown signal.
    # In my main async function:
    supabase_channel = supabase.realtime.channel("my_table_changes")
    await (
        supabase_channel
            .on_postgres_changes(event="INSERT", ..., callback=my_async_insert_handler)
            .on_postgres_changes(event="UPDATE", ..., callback=my_async_update_handler)
            .subscribe()
    )
    # The service then waits indefinitely on an asyncio.Event for a shutdown signal.

3. The callback functions (
my_async_..._handler
my_async_..._handler
) are
async
async
and use
asyncio.create_task
asyncio.create_task
to process events without blocking the listener.

Problem:
The Realtime connection works perfectly for a while, but eventually (often after several hours or a day) it seems to silently time out or disconnect. The service doesn't crash and no exceptions are raised, but it simply stops receiving any new database change events.

Question:
What is the recommended, robust pattern for handling these silent timeouts with
supabase-py
supabase-py
's async Realtime client? Is there a built-in auto-reconnect mechanism that I'm not implementing correctly, or what would be the idiomatic solution for a heartbeat/health check and resubscribe logic to ensure the connection stays alive?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Python realtime messages
SupabaseSSupabase / help-and-questions
3y ago
supabase realtime in python
SupabaseSSupabase / help-and-questions
3y ago
Realtime Subscriptions Timeout in Docker
SupabaseSSupabase / help-and-questions
5mo ago
Realtime selfhost issue
SupabaseSSupabase / help-and-questions
8mo ago