Skip to content

[Realtime] RealtimeV2 auto-reconnects after calling disconnect() #612

Closed
@TiagoLira

Description

@TiagoLira

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.

Version

supabase-swift 2.23.0

Describe the bug

I had asked before about the client not reconnecting, and it seems that it is reconnecting too well now :)
What happens is that after I call realtimeV2.disconnect(), it immediately triggers an error on the client's messageTask task and starts a reconnect.
I couldn't find any way to disconnect it properly.

To Reproduce

My use case is that I want to unsubscribe and disconnect when the app goes to the background.
When I connect I simply subscribe to a channel and listen for statusChanges.
When the app goes to background I run:

let realtime = client.realtimeV2
if let channel = realtimeChannel {
    await realtime.removeChannel(channel)
 }
realtime.disconnect()
realtimeChannel = nil

Right after this, the reconnect() call is triggered on messageTask.

Expected behavior

The client should not try to reconnect if disconnect() is called.

System information

  • OS: iOS 18

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions