2

I am new to Realm and Android development and am trying to query a document from Atlas. I am able to successfully authenticate users, but when I try to perform a query, I get the following error: E/REALM_JAVA: Session Error[wss://realm.mongodb.com/]: WRONG_PROTOCOL_VERSION(realm::sync::ProtocolError:105): sync client must have a sync protocol version of at least 3 to sync on this application, but found version 2. Please update your application to use a newer SDK

I am currently working on version 10.4.0 of the Android Realm SDK and Android SDK Platform 30. I have tried looking for updates for both and it says that everything is up to date. Here is my code:

app.loginAsync(emailPasswordCredentials, it -> {
        if (it.isSuccess()) {
            Log.v("AUTH", "Successfully authenticated using an email and password.");
            User user = app.currentUser();
            String partitionValue = "object_id";
            SyncConfiguration config = new SyncConfiguration.Builder(
                    user,
                    partitionValue)
                    .allowQueriesOnUiThread(true)
                    .allowWritesOnUiThread(true)
                    .build();
            uiThreadRealm = Realm.getInstance(config);
            
            //Debugging - testing Realm Sync queries
            Products product = uiThreadRealm.where(Products.class).equalTo("_id", 4).findFirst();
            if (product != null) {
                Log.v("AUTH", product.toString());
            }
            Log.v("AUTH", config.toString());
            //In-App functions
 }

Does anyone have any way to solve this issue?

Deepti V.
  • 21
  • 1
  • Hey, in your server schema, have you declared a Set or a Dictionary property? They should look like `{ "bsonType": "object", "additionalProperties": "true" }` for dictionary and `{ "bsonType": "array", "uniqueItems": true }` for Set. Those types are not yet supported in a stable Realm Java release, so you should probably not use them or upgrade to a snapshot version that supports them. – Nikola Irinchev Apr 03 '21 at 20:41
  • 2
    Hi, were you able to resolve this error? The MongoDB Realm documentation is severely lacking in terms of how to handle sync errors. – AMS Apr 12 '21 at 20:06

2 Answers2

0

In my case it was due to selecting UUID as the type of one my fields, which is "at this time is NOT a supported type in the SDK, but it will be in a future version." (from Monogo's support).

omerts
  • 8,485
  • 2
  • 32
  • 39
0

For those coming from react-native and get this kind of error

sync client must have a sync protocol version of at least 3 to sync on this application, but found version 2. Please update your application to use a newer SDK

Just do in your terminal

npm install realm

Then

cd ios
pod install

Be careful of breaking changes.

If needed, uninstall your application on your emulator/simulator then

npx react-native run-ios

or

npx react-native run-android

So for Android I guess you have to update your Realm packages as well...

XplosiVe06
  • 568
  • 3
  • 23