firebase / firebase/firebase-ios-sdk

Realtime Database stays offline and doesn't reconnect after sleeping

Open
#9,682 47 comments 0 reactions 2 assignees Claimed by @maneesht View on GitHub
api: database macOS
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### [REQUIRED] Step 1: Describe your environment

* Xcode version: 13.2.1
* Firebase SDK version: 8.15.0
* Installation method: CocoaPods
* Firebase Component: Database
* Target platform(s): macOS

### [REQUIRED] Step 2: Describe the problem

#### Steps to reproduce: Have the mac going to sleep. After waking up, sometimes (with really low frequency), the Realtime Database client would stay offline indefinitely, even if network conditions are good.

We have an app that uses Realtime Database for implementing Presence in Firestore. https://firebase.google.com/docs/firestore/solutions/presence. If we have the app running and the mac goes to sleep, sometimes, after waking up, the Realtime Database client doesn't reconnect.

We have strong evidence that `database.reference(withPath: ".info/connected").observe` reported a `false` value while the mac was sleeping but it never reported `true` again, even after waking up and having good network conditions.

If we use any operation while Realtime database is offline, like statusReference.setValue to write to the database, the operation never runs the completion callback.

Firestore is able to reconnect properly without problems but Realtime Database client is not working properly.

We saw one case that recovered by itself after a some hours (12 hours after disconnected, 2 hours after the mac woke up). But as we need the Realtime Database to implement Presence, that delay is not acceptable.

Restarting the app makes it work again.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.