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>
);
}
Anyone could help me?