Blocking error when no internet connection in C++ SDK

I am working on an app with the preview Realm C++ SDK. I tested with internet off, and I get these error messages:

Failed to connect to sync: Host not found (authoritative)

Is there a way to use a synced Realm while also supporting offline operations?

1 Like

I have the same issue with the React Native SDK. On iOS the app will crash when starting with no internet on, and Android it will crash the app when the internet is disconnected or app opened with no internet.

iOS fails with:
[error] Failed to resolve ‘ws.realm.mongodb.com:443’: Host not found (authoritative)

libc++abi: terminating due to uncaught exception of type facebook::jsi::JSError: Failed to connect to sync: Host not found (authoritative)

I’m not sure when this started happening and not aware of any reason why the app shouldn’t be able to start and run properly while offline with already synced data?

On first open of an app that has no connection I expect this error as the DNS resolution will fail. If however this is a subsequent app launch you can use your Realm normally once you have a cached user and your sync subscriptions set up from a previous app launch.

Yeah, this is on subsequent launches, the app already has data and will crash if I force close and reopen with airplane mode on. On Android the app will crash while open if I turn on airplane mode, and crash when reopening too.

Latest version of the react native SDK

I use the rerunOnOpen option for initialSubscriptions and wondered if this triggered the cache but turning it off does not seem to help.

example of the sync config:

<RealmProvider
      sync={{
        user: app.currentUser,
        flexible: true,
        clientReset: {
          mode: ClientResetMode.DiscardUnsyncedChanges,
        },
        initialSubscriptions: {
          rerunOnOpen: true,
          update: (subs, realm) => {
            ...
          },
        },
        onError: errorSync,
        newRealmFileBehavior: { type: 'openImmediately' }, 
        existingRealmFileBehavior: { type: 'openImmediately' },
      }}>
      ...
```

I have worked out this is an issue in our codebase, we throw the exception after handing it in our custom handler which crashed the app! Not a realm/library issue at all.