- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 376
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
- [ x ] I confirm this is a bug with Supabase, not with my own application.
- [ x ] I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
My supabase realtime listener stops receiving events after a while, without giving an errors.
To Reproduce
Here is the code snippet I'm using
async def realtime_insert_table_listener(table: str, cb: callable):
    while True:
        try:
            await async_supabase.realtime.connect()
            while not async_supabase.realtime.is_connected:
                await asyncio.sleep(0.2)
            channel = async_supabase.channel(table)
            channel.on_postgres_changes(
                event="INSERT",
                schema="public",
                table=table,
                callback=cb,
            )
            
            await channel.subscribe(
                lambda status, err: status
                == RealtimeSubscribeStates.SUBSCRIBED
                and logger.info("Successfully subscribed")
            )
            while True:
                await asyncio.sleep(10)
        except ConnectionClosedError as exc:
            logger.warning(
                "Connection closed unexpectedly: %s. Will retry...", exc
            )
        except Exception as exc:
            logger.exception(
                "Error in realtime listener: %s. Will retry...", exc
            )
        finally:
            try:
                if async_supabase.realtime.is_connected:
                    logger.info("Closing realtime connection...")
                    await async_supabase.realtime.close()
            except Exception:
                logger.exception("Error while closing realtime connection")
        # Backoff or small delay before attempting to reconnect
        logger.info("Will attempt to reconnect in 5 seconds...")
        await asyncio.sleep(5)System information
- OS: ubuntu
package information:
>>> supabase.__version__
'2.15.2'
>>> realtime.__version__
'2.4.3'
>>> websockets.__version__
'14.2'
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working