Realm Sync not happening when app started without data connectivity. Using Realm SDK for Java

Im using Java Realm SDK.
The app works fine when network connectivity is available. App even works when i turn off data connectivity after opening app.
But when i restart app with no data connectivity. It is unable to fetch the local data.

How to Reproduce:
Turn off data connectivity.
Open app
App unable to sync.

What I got after diagnosing:

After I restart the app without data connectivity. The app is unable to set SyncConfiguration as a result realm is not able to fetch any data.
Hence as Mongo says it is offline first I’m able to use this important feature.

But when I turn off data while running app. the app works fine. as SyncConfiguration is already set.

This is My sync configuration:


config = new SyncConfiguration.Builder(app.currentUser())
                    .allowWritesOnUiThread(true)
                    .allowQueriesOnUiThread(true)
                    .compactOnLaunch()
                    .waitForInitialRemoteData(500, TimeUnit.MILLISECONDS)
                    .initialSubscriptions(new SyncConfiguration.InitialFlexibleSyncSubscriptions() {
                        @Override
                        public void configure(Realm realm, MutableSubscriptionSet subscriptions) {
                            // add a subscription with a name
                            Log.e(TAG, "configure: ");

                            Subscription userSubscription = subscriptions.find(kMap.userSubs);
                            if (userSubscription == null) {
                                subscriptions.addOrUpdate(Subscription.create(kMap.userSubs,
                                        realm.where(users.class)));
                            }

                            Subscription collegeSubscription = subscriptions.find(kMap.collegeSubs);
                            if (collegeSubscription == null) {
                                subscriptions.addOrUpdate(Subscription.create(kMap.collegeSubs,
                                        realm.where(colleges.class)));
                            }

                            Subscription courseSubscription = subscriptions.find(kMap.courseSubs);

                            if (courseSubscription == null) {
                                subscriptions.addOrUpdate(Subscription.create(kMap.courseSubs,
                                        realm.where(courses.class)));
                            }

                            Subscription studentsSubs = subscriptions.find(kMap.studentsSubs);
                            if (studentsSubs == null) {
                                subscriptions.addOrUpdate(Subscription.create(kMap.studentsSubs,
                                        realm.where(students.class)));
                            }


                            realm.close();
                        }
                    })
                    .build();

            Realm.setDefaultConfiguration(config);
            StaticValues.syncCount++;

Error I get while internet is off:

E/REALM_JAVA: Session Error[wss://realm.mongodb.com/]: UNKNOWN(realm.util.network.resolve:1): Host not found (authoritative)
E/REALM_SYNC: Failed to resolve ‘ws.ap-south-1.aws.realm.mongodb.com:443’: Host not found (authoritative)