Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm sync offline not opening. Realm not behaving like offline-first. Works like online-only #7859

Closed
hkchakladar opened this issue Nov 21, 2023 · 4 comments
Labels
Encryption:Off Frequency:Always More-information-needed More information needed from the reporter. The issue will autoclose if no more information is given. O-Community Repro:Always SDK-Use:Sync T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed

Comments

@hkchakladar
Copy link

How frequently does the bug occur?

Always

Description

Expectation :
Realm.getInstance() to load faster whether online/offline like any other offline library and continue read/write ops. And Realm check network connection, sync in background.

What actually happened :
Realm not behaving like offline-first. Works like online-only. Realm is not opening in Offline mode and taking very long in online.

When online, Realm.getInstanceAsync takes long time to load, based on network speed. On fast network it takes ~1000ms and on slow network it takes almost 10-20 seconds.

This freeze the UI and makes it unsable.

Stacktrace & log output

2023-11-21 19:58:57.841 26613-26796 REALM_SYNC              com.in                   E  Failed to resolve 'ws.asia-south1.gcp.realm.mongodb.com:443': Host not found (authoritative)
2023-11-21 19:58:57.845 26613-26796 REALM_JAVA              com.in                   W  Unknown error code: 'unknown:1999'
2023-11-21 19:58:57.845 26613-26796 REALM_JAVA              com.in                   W  Unknown error code: 'unknown:1999'
2023-11-21 19:58:57.846 26613-26796 REALM_JAVA              com.in                   E  Session Error[wss://realm.mongodb.com/]: UNKNOWN(unknown:1999): WebSocket: Resolve Failed
2023-11-21 19:58:58.634 26613-26796 REALM_SYNC              com.in                   E  Failed to resolve 'ws.asia-south1.gcp.realm.mongodb.com:443': Host not found (authoritative)
2023-11-21 19:58:58.634 26613-26796 REALM_JAVA              com.in                   W  Unknown error code: 'unknown:1999'
2023-11-21 19:58:58.635 26613-26796 REALM_JAVA              com.in                   W  Unknown error code: 'unknown:1999'
2023-11-21 19:58:58.635 26613-26796 REALM_JAVA              com.in                   E  Session Error[wss://realm.mongodb.com/]: UNKNOWN(unknown:1999): WebSocket: Resolve Failed
2023-11-21 19:59:00.191 26613-26796 REALM_SYNC              com.in                   E  Failed to resolve 'ws.asia-south1.gcp.realm.mongodb.com:443': Host not found (authoritative)
2023-11-21 19:59:00.193 26613-26796 REALM_JAVA              com.in                   W  Unknown error code: 'unknown:1999'
2023-11-21 19:59:00.194 26613-26796 REALM_JAVA              com.in                   W  Unknown error code: 'unknown:1999'
2023-11-21 19:59:00.194 26613-26796 REALM_JAVA              com.in                   E  Session Error[wss://realm.mongodb.com/]: UNKNOWN(unknown:1999): WebSocket: Resolve Failed

Can you reproduce the bug?

Always

Reproduction Steps

Here is my code :

long startTime = System.currentTimeMillis();

app = new App(new AppConfiguration.Builder("app-id").build());

if (app.currentUser() != null) {

    Log.e(TAG, "onCreate: Realm user already logged in uid -> " + app.currentUser().getIdentities());

    SyncConfiguration config = new SyncConfiguration.Builder(app.currentUser())
            .initialSubscriptions(new SyncConfiguration.InitialFlexibleSyncSubscriptions() {
                @Override
                public void configure(Realm realm, MutableSubscriptionSet subscriptions) {
                    subscriptions.addOrUpdate(Subscription.create(
                            realm.where(RealmCustomerModel.class).equalTo("uid", app.currentUser().getId()))
                    );

                    subscriptions.addOrUpdate(Subscription.create(
                            realm.where(RealmTxnModel.class).equalTo("uid", app.currentUser().getId()))
                    );
                }
            }).build();

    Log.e(TAG, "Realm getInstance/Async started");

    Realm.getInstanceAsync(config, new Realm.Callback() {
        @Override
        public void onSuccess(Realm realm) {
            uiThreadRealm = realm;
            Log.e(TAG, "onSuccess: Realm getInstanceAsync success in " + (System.currentTimeMillis() - startTime) + "ms");
            populateUi();
            Realm.setDefaultConfiguration(config);
        }
    });
}

Is the configuration correct or am I doing something wrong?

Version

10.15.1

What Atlas App Services are you using?

Atlas Device Sync

Are you using encryption?

No

Platform OS and version(s)

Android 12

Build environment

Android Studio version: Android Studio Giraffe | 2022.3.1 Patch 2
Android Build Tools version: ...
Gradle version: 8.1.2

@clementetb
Copy link
Collaborator

clementetb commented Dec 4, 2023

Hi @hkchakladar by any chance are you behind a VPN or proxy? Do you have any special network configuration on this machine?

In your report you explain that the app is slow on loading, is this happening on the first load only, or does it happen on any subsequent loads?

When you say slow, does it mean the UI is blocked and showing ANR's or the data is not populated?

Could you enable RealmLog level Trace and share the logs you get during the connection?

@sync-by-unito sync-by-unito bot added More-information-needed More information needed from the reporter. The issue will autoclose if no more information is given. Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Dec 4, 2023
Copy link

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@vineetpandita10
Copy link

I am also facing the same issue with reactNative sdk. when online ->works fine, after an initialSync when net is turned off-> works fine, when opening app without net then gives error -> ERROR [error] Failed to resolve 'ws.ap-south-1.aws.realm.mongodb.com:443': Host not found (authoritative)

@nirinchev
Copy link
Member

Can you open a new issue in the correct repo? Then the correct team can help you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Encryption:Off Frequency:Always More-information-needed More information needed from the reporter. The issue will autoclose if no more information is given. O-Community Repro:Always SDK-Use:Sync T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed
Projects
None yet
Development

No branches or pull requests

4 participants