Realm for React Native not work offline

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintableJSON

      How frequently does the bug occur?

      Always

      Description

      Hi, i’m using realm for a react native application.
      I receive SyncError: Failed to connect to sync: Host not found (authoritative) error when turn off wifi. But i have read mongo realm is offline first…

      I open realm like this:

      function AuthProvider() {
        const [visible, setVisible] = useState<boolean>(false);
        const [error, setError] = useState<string>('');
      
        const user = useUser();
        console.log('user', user);
      
        const realmAccessBehavior: Realm.OpenRealmBehaviorConfiguration = {
          type: Realm.OpenRealmBehaviorType.DownloadBeforeOpen,
          timeOutBehavior: Realm.OpenRealmTimeOutBehavior.OpenLocalRealm,
          timeOut: 3000,
        };
      
        return (
          <RealmProvider
            schema={[
              Invoice,
              Operator,
              Customer,
              Report,
              ReportDetail,
              Manpower,
              Material,
              RightToCall,
            ]}
            sync={{
              flexible: true,
              newRealmFileBehavior: realmAccessBehavior,
              existingRealmFileBehavior: realmAccessBehavior,
              initialSubscriptions: {
                update(subs, realm) {
                  subs.add(realm.objects(Invoice));
                  subs.add(realm.objects(Customer));
                  subs.add(realm.objects(Operator));
                  subs.add(realm.objects(Report));
                },
                rerunOnOpen: true,
              },
              onError: (_session, err) => {
                console.log('error', err);
                setError(err.message);
                setVisible(true);
              },
            }}>
            <App />
            <ErrorDialog
              errorTitle="Errore di Sincronizzazione"
              errorMsg={error}
              visible={visible}
              setVisible={setVisible}
            />
          </RealmProvider>
        );
      }
      
      

      Stacktrace & log output

      03-14 16:25:28.255 6242 6302 W ReactNativeJS:
      03-14 16:25:28.255 6242 6302 W ReactNativeJS: URL: 10.0.2.2:8081
      03-14 16:25:28.255 6242 6302 W ReactNativeJS:
      03-14 16:25:28.255 6242 6302 W ReactNativeJS: Error: Software caused connection abort
      03-14 16:25:28.389 6242 6302 I ReactNativeJS: 'Connection state changed', 'active'
      03-14 16:25:29.083 6242 6302 I ReactNativeJS: 'Connection state changed', 'active'
      03-14 16:25:29.099 6242 6302 E ReactNativeJS: [error] Failed to resolve 'ws.eu-west-1.aws.realm.mongodb.com:443': Host not found (authoritative)
      03-14 16:25:29.100 6242 6302 I ReactNativeJS: 'Connection state changed', 'active'
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: 'error', { [SyncError: Failed to connect to sync: Host not found (authoritative)]
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: name: 'SyncError',
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: isOk: false,
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: reason: 'Failed to connect to sync: Host not found (authoritative)',
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: code: 1034,
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: category: 'UNKNOWN',
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: logUrl: '',
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: userInfo: {},
      03-14 16:25:29.101 6242 6302 I ReactNativeJS: isFatal: false }
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: 'user', { listeners:
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: { listeners: {},
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: options:

      { add: [Function: add], remove: [Function: remove] }

      },
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: internal: {},
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: app:
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: { listeners:
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: { listeners: {},
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: options:

      { add: [Function: add], remove: [Function: remove] }

      },
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: internal: {} },
      03-14 16:25:29.104 6242 6302 I ReactNativeJS: cachedProfile: undefined }
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: 'user', { listeners:
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: { listeners: {},
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: options:

      { add: [Function: add], remove: [Function: remove] }

      },
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: internal: {},
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: app:
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: { listeners:
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: { listeners: {},
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: options:

      { add: [Function: add], remove: [Function: remove] }

      },
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: internal: {} },
      03-14 16:25:29.323 6242 6302 I ReactNativeJS: cachedProfile: undefined }

      Can you reproduce the bug?

      Always

      Reproduction Steps

      • Start application in an Emulator.
      • Go offline, disabling wifi

      Version

      0.6.2

      What services are you using?

      Atlas Device Sync

      Are you using encryption?

      No

      Platform OS and version(s)

      Windows 10, React Native, Android 14

      Build environment

      adb logcat

      Cocoapods version

      No response

              Assignee:
              Unassigned
              Reporter:
              Unito Sync Bot
              Archiver:
              Marc Greenfield

                Created:
                Updated:
                Resolved:
                Archived: