S
Supabase19h ago
Zerz

Realtime Broadcast Subscription fails when started without Internet connection

When initializing a Realtime Broadcast subscription while there is no internet connection, the subscription never recovers once the network becomes available again. Steps to reproduce:     1.    Create a Supabase Realtime channel with a Broadcast event (as described in the documentation: https://supabase.com/docs/guides/realtime/broadcast?queryGroups=language&language=swift&queryGroups=http&http=curl).     2.    Launch the app while offline (e.g. disable Wi-Fi).     3.    Wait for 30–60 seconds.     4.    Re-enable the network (e.g. turn Wi-Fi back on).     5.    The myChannel.subscribe() call executes, but no events are received and channel.status remains "unsubscribed".     6.    Even after several minutes, the channel never transitions to a subscribed state and no events are delivered. Expected behavior: The subscribe() call should be resilient to temporary network loss. Regardless of the network state at the time of calling subscribe(), the Realtime client should automatically perform the subscription once connectivity is restored. Additional information: This behavior is consistently reproducible with the sample code below. Tested with: - iPhone 17 Pro Simulator (iOS 26.0) - Swift Supabase SDK Version 2.36.0 (integrated via SPM with URL https://github.com/supabase/supabase-swift.git) // //  RealtimeTestApp.swift //  RealtimeTest // //  Created by Flo on 28.10.25. // import SwiftUI import SwiftData import Combine import Supabase @main struct RealtimeTestApp: App {     @State private var appManager = AppManager()          var body: some Scene {         WindowGroup {             Text("Hello World")         }     } } final class AppManager: ObservableObject {     var supabase:SupabaseClient          init() {         supabase = SupabaseClient(             supabaseURL: URL(string: "myUrl")!,             supabaseKey: "myKey"         )         startRealtime()     }          func startRealtime() {         Task {             let myChannel = await supabase.channel("myChannel")             let broadcastStream = await myChannel.broadcast(event: "myEvent")                          Task {                 for await status in myChannel.statusChange {                     print("channel status changed: \(status)")                 }             }                          await myChannel.subscribe()             for await event in broadcastStream {               print(event)             }         }     }           } Am I missing something here or is there a solution? Kind regards, Sebastian
1 Reply
garyaustin
garyaustin17h ago
Realtime has no queue (at this point) so would lose any data changes made while disconnected.
I don't know precisely about starting up without internet connection but in general it has error with the drop of internet after several tries and also if a tab goes into background and power saving mode. They have added a webworker option to help with maintaining connections with background mode.
Also you can't refresh the JWT so it will error out after awhile anyway if using a signed in user.

Did you find this page helpful?