低连接时领域对象服务器同步。

Realm object server sync on low connection.

我有一个领域对象服务器并尝试与 android 设备同步数据,例如:

SyncCredentials syncCred = SyncCredentials
            .usernamePassword(username, password, false);
SyncUser.loginAsync(syncCred, url, new SyncUser.Callback() {
        @Override
        public void onSuccess(SyncUser user) {
        ...some code...
        }

        @Override
        public void onError(ObjectServerError error) {}

它在 wi-fi 上工作得很好,但如果互联网连接较低(例如为模拟器设置 GSM 网络类型),我会收到错误消息(onError (ObjectServerError error) 调用):

java.net.ProtocolException: unexpected end of stream
at okhttp3.internal.http.Http1xStream$FixedLengthSource.read(Http1xStream.java:380)
at okio.Buffer.writeAll(Buffer.java:993)
at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:106)
at okhttp3.ResponseBody.bytes(ResponseBody.java:128)
at okhttp3.ResponseBody.string(ResponseBody.java:154)
at io.realm.internal.network.AuthenticateResponse.from(AuthenticateResponse.java:51)
at io.realm.internal.network.OkHttpAuthenticationServer.authenticate(OkHttpAuthenticationServer.java:125)
at io.realm.internal.network.OkHttpAuthenticationServer.loginUser(OkHttpAuthenticationServer.java:53)
at io.realm.SyncUser.login(SyncUser.java:199)
at io.realm.SyncUser.run(SyncUser.java:234)
at io.realm.SyncUser$Request.run(SyncUser.java:585)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

at io.realm.internal.network.AuthenticateResponse.from(AuthenticateResponse.java:53)
at io.realm.internal.network.OkHttpAuthenticationServer.authenticate(OkHttpAuthenticationServer.java:125)
at io.realm.internal.network.OkHttpAuthenticationServer.loginUser(OkHttpAuthenticationServer.java:53)
at io.realm.SyncUser.login(SyncUser.java:199)
at io.realm.SyncUser.run(SyncUser.java:234)
at io.realm.SyncUser$Request.run(SyncUser.java:585)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

是否可以通过低 Internet 连接同步数据?

issue have been fixed in 4.1.0