Realm data is not synced between different devices
See original GitHub issueI’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:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Thanks, so let me summarize what shall I do.
onStart()
and close inonStop()
in activityonStart()
?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
andonStop
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)