realm-java: Failing to open synced realm after problems with internet.
Goal
Open synced realm using Realm.getInstanceAsync.
Expected Results
onSuccess called in provided callback
Actual Results
onError called with Throwable where message is set to “UNKNOWN(-1) It was not possible to download all remote changes. Has the SyncClient been started?”
Steps & Code to Reproduce
- call Realm.getInstanceAsync with waitForInitialRemoteData() set in configuration.
- if something happened while data is downloading (internet connection lost, or user disable wifi or enter airplane mode) onError called with proper message. This works as expected.
- Restore connection to internet
- Try to connect again with same configuration.
- onError called with message that downloading is not possible.
If you restart application - all works fine.
Code Sample
RealmConfiguration config = new SyncConfiguration.Builder(user, getServerURL()).schemaVersion(SCHEMA_VERSION).disableSSLVerification().waitForInitialRemoteData().build();
Realm.getInstanceAsync(config, new Realm.Callback() {
@Override
public void onError(@NonNull Throwable exception) {
user.logout();
onFinished("migrateRealm exception: " + exception.getMessage());
}
@Override
public void onSuccess(@NonNull Realm realm) {
Realm localRealm = Realm.getDefaultInstance();
realm.beginTransaction();
realm.copyToRealmOrUpdate(...);
realm.commitTransaction();
realm.close();
localRealm.close();
onFinished(null);
}
});
Version of Realm and tooling
Realm version(s): 4.3.1 Realm sync feature enabled: yes Android Studio version: 3.0.1 Which Android version and device: any
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 20 (9 by maintainers)
Commits related to this issue
- Fixes #5677 - removed session network listener since it's redundant with the SyncManager one — committed to realm/realm-java by nhachicha 6 years ago
- Fixes #5677 (#5741) * Fixes #5677 - removed session network listener since it's redundant with the SyncManager one — committed to realm/realm-java by nhachicha 6 years ago
Realm
4.3.4
released@nhachicha It’s ok. There is no sync problem on version 4.4.0-SNAPSHOT. Thank you for the fix.
Probably you can also close issue #5579, it is the same problem I think.