question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Realm data is not synced between different devices

See original GitHub issue

I’m using syncconfiguration and ROS to sync data between two devices. Initially, the data was able to syn without any trouble. But after I modified the schema and created a new Realm, when I save the data in the first device, the second device cannot syn the data. Even though the data was saved in the server successfully.

So I did some simple tests. When I uninstall and reinstall the app in the first device, the data was also not synced initially, but if I wrote anything new, the data got synced. Did I miss anything in the sync configuration?

Also, when I query, I can get the correct results but an error showed up.

06-01 09:47:57.144 D/REALM_JAVA: AuthenticateResponse - Error: UNKNOWN(-1)
                                 java.io.InterruptedIOException: thread interrupted
                                     at okio.Timeout.throwIfReached(Timeout.java:146)
                                     at okio.Okio$1.write(Okio.java:75)
                                     at okio.AsyncTimeout$1.write(AsyncTimeout.java:180)
                                     at okio.RealBufferedSink.flush(RealBufferedSink.java:216)
                                     at okhttp3.internal.http.Http1xStream.finishRequest(Http1xStream.java:161)
                                     at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:51)
                                     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                     at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
                                     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
                                     at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
                                     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
                                     at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
                                     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
                                     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
                                     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
                                     at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
                                     at okhttp3.RealCall.execute(RealCall.java:60)
                                     at io.realm.internal.network.OkHttpAuthenticationServer.authenticate(OkHttpAuthenticationServer.java:110)
                                     at io.realm.internal.network.OkHttpAuthenticationServer.loginToRealm(OkHttpAuthenticationServer.java:63)
                                     at io.realm.SyncSession$2.execute(SyncSession.java:225)
                                     at io.realm.SyncSession$2.execute(SyncSession.java:221)
                                     at io.realm.internal.network.ExponentialBackoffTask.run(ExponentialBackoffTask.java:66)
                                     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
                                     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                     at java.lang.Thread.run(Thread.java:818)

Version of Realm and tooling

Realm version(s): 3.1.1

Realm sync feature enabled: yes

Android Studio version: 2.3.2

Android version and device: Samsung S6 (Android 6.0.1), Lenovo Phablet (Android 6.0.1)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Insane-nealcommented, Jun 1, 2017

Thanks, so let me summarize what shall I do.

  1. update realm to at least 3.1.3?
  2. open realm in onStart() and close in onStop() in activity
  3. add change listener to update every realm schema at onStart() ?
1reaction
Insane-nealcommented, Jun 5, 2017

The issue was solved. The error was because the realm was closed in every function. Now I am following @Zhuinden suggestion to manage the realm instance in onStart and onStop in an Activity.

The realm not syncing issue was solved by adding waitForInitialRemoteData in the sync configuration. It wasn’t available in the version I was using (3.1.1)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sync Changes Between Devices - Realm Java SDK - MongoDB
Sync Changes Between Devices - Java SDK · Prerequisites · Open a Synced Realm · Sync Data · Pause or Resume a Sync...
Read more >
Synchronise Realm data between devices - Stack Overflow
The only thing I can say for sure is that the Realm database cannot (and may not) be synced across devices using a...
Read more >
Realm Mobile (Sync) - YouTube
Realm Sync Demo for Mobile Apps - MongoDB RealmSubscribe to MongoDB ▻▻▻ https://bit.ly/3bpg1Z1Connect with MongoDB:Website: ...
Read more >
Realm Flexible Sync Demo - YouTube
This new method of syncing puts the power into the hands of the developer. Now, developers can get more granular control over the...
Read more >
[Solved]-Synchronise Realm data between devices-swift
Previous answer: It's not possible. The binary format for the Realm database on the device is not synced on any service like iCloud...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found