Query based sync not working


Hi all,

Having issues using Realm Platform to read data from default (/default) realm. I’m using Cloud version 3.9 and latest Nuget package 3.1.0 for Xamarin.

My issues:

  • My app is not getting any data when calling Realm.All<> method even if I can see it in Realm Studio.
  • Most times it will fail when trying to add an object using Ream.Write method, confirmed by checking RealmStudio. But sometimes it actually writes data to Realm and not necessarily new data. It can be from several debug sessions ago.

I’m connecting like this:

           var credentials = Credentials.Nickname(user_name, isAdmin: false);
            var authURL = new System.Uri("https://<myrealm name>.de1a.cloud.realm.io");
            var user = await User.LoginAsync(credentials, authURL);
            var serverURL = new System.Uri("realms://<myrealm name>.de1a.cloud.realm.io");
            RealmConfiguration.DefaultConfiguration = new QueryBasedSyncConfiguration(user: user);

                Realm = Realm.GetInstance();
                Realm.Error += (session, args) =>
                    var se = (SessionException)args.Exception;
                    Debug.WriteLine("SessionException: "+se);
            catch (Realms.Exceptions.RealmException e)
            { }

I get no exceptions and no errors in the debug log.

And querying like this:

var FavoriteLocations = GameEngine.Realm.All<FavoriteLocation>(); 

Listening for notifications like this:

TokenLocations = FavoriteLocations.SubscribeForNotifications<FavoriteLocation>((sender, changes, error)

When adding a FavoriteLocation it calls the listener twice, first with a changes.InsertedIndices then a second time with a changes.DeletedIndices. Is this a rollback?

Any ideas to what could be the issue?

Brgds Lars


@Larsfs Are you able to login and get a user? Can you please up your logs to trace on the client and server side and share?


Yeah. Login works fine. And I can write objects and confirm them in Realm studio. It is reading them which fails.

Support tells me to add .Subscribe() om my query for a partial realm, but that method is not available. Will recheck my Nuget is correctly installed…

Brgds Lars


.Subscribe is an extension method from the Realms.Sync namespace - can you try adding a using statement and check if it shows up? Also, can you post an example query you have?


Of course. Checked the API. Thanks :slight_smile: