我使用Azure移动服务将一个Android应用程序连接到Azure。我已经实现了离线同步,并创建了一个后台异步流程,每隔15分钟就可以在应用和云之间同步数据。
我按下电源/睡眠按钮,它在第一个小时左右工作但在我从同步过程中收到错误之后:
11-20 13:09:22.537 2522-3106/com.mycompany.myapp W/System.err: java.util.concurrent.ExecutionException: com.microsoft.windowsazure.mobileservices.MobileServiceException: Error while processing request.
11-20 13:09:22.547 2522-3106/com.mycompany.myapp W/System.err: at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:299)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:286)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at com.mycompany.myapp.DatabaseAccess$2.doInBackground(DatabaseAccess.java:1195)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at com.mycompany.myapp.DatabaseAccess$2.doInBackground(DatabaseAccess.java:1186)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:292)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-20 13:09:22.557 2522-3106/com.mycompany.myapp W/System.err: at java.lang.Thread.run(Thread.java:818)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: Caused by: com.microsoft.windowsazure.mobileservices.MobileServiceException: Error while processing request.
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at com.microsoft.windowsazure.mobileservices.http.MobileServiceConnection$1.onNext(MobileServiceConnection.java:138)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at com.microsoft.windowsazure.mobileservices.MobileServiceClient$15.handleRequest(MobileServiceClient.java:1610)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at com.microsoft.windowsazure.mobileservices.http.MobileServiceConnection.start(MobileServiceConnection.java:113)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at com.microsoft.windowsazure.mobileservices.http.RequestAsyncTask.doInBackground(RequestAsyncTask.java:78)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at com.microsoft.windowsazure.mobileservices.http.RequestAsyncTask.doInBackground(RequestAsyncTask.java:35)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: ... 5 more
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: Caused by: java.net.ConnectException: failed to connect to myappapp.azurewebsites.net/[IP ADDRESS] (port 443) after 120000ms: isConnected failed: EHOSTUNREACH (No route to host)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at libcore.io.IoBridge.isConnected(IoBridge.java:238)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:122)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at java.net.Socket.connect(Socket.java:882)
11-20 13:09:22.567 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.internal.Platform$Android.connectSocket(Platform.java:190)
11-20 13:09:22.577 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.Connection.connectSocket(Connection.java:196)
11-20 13:09:22.577 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.Connection.connect(Connection.java:172)
11-20 13:09:22.577 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:367)
11-20 13:09:22.577 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
11-20 13:09:22.577 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
11-20 13:09:22.577 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.Call.getResponse(Call.java:267)
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: at com.squareup.okhttp.Call.execute(Call.java:79)
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: at com.microsoft.windowsazure.mobileservices.http.ServiceFilterRequestImpl.execute(ServiceFilterRequestImpl.java:164)
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: at com.microsoft.windowsazure.mobileservices.http.MobileServiceConnection$1.onNext(MobileServiceConnection.java:121)
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: ... 9 more
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: Caused by: android.system.ErrnoException: isConnected failed: EHOSTUNREACH (No route to host)
11-20 13:09:22.587 2522-3106/com.mycompany.myapp W/System.err: at libcore.io.IoBridge.isConnected(IoBridge.java:223)
11-20 13:09:22.597 2522-3106/com.mycompany.myapp W/System.err: ... 27 more
有关其发生原因和解决方法的任何想法?我使用三星平板电脑作为我的测试设备。
答案 0 :(得分:0)
使用刷新标记
Azure App Service身份验证和授权返回的令牌有一个 定义一小时的寿命。在此期限之后,您必须重新验证用户。 How to use the Azure Mobile Apps SDK for Android
您的身份验证令牌需要在1小时后刷新。您可以通过调用.login()或.refreshUser()方法来实现此目的。如果您成功完成此操作,请发布您的代码。