我有一个 Realm 对象服务器,并尝试与 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$1.run(SyncUser.java:234)
at io.realm.SyncUser$Request$1.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$1.run(SyncUser.java:234)
at io.realm.SyncUser$Request$1.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)
是否可以通过低互联网连接同步数据?
该问题已在 4.1.0 中修复