0

I've got an Android App connected to Azure using Azure Mobile Services. I have implemented offline sync and have created a background async process to sync the data between app and cloud every 15 minutes.

I press the power/sleep button and it works for the first hour or so but after I get an error from the sync process:

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

Any ideas on why its happening and how to fix it? I'm using a Samsung Tablet as my test device.

SliderUK
  • 167
  • 14

1 Answers1

0

Use Refresh Tokens

The token returned by Azure App Service Authentication and Authorization has a
defined life time of one hour. After this period, you must reauthenticate the user. How to use the Azure Mobile Apps SDK for Android

Your authentication token needs to be be refreshed after 1 hour. You can achieve this by calling .login() or .refreshUser() methods. Please post your code if you manage to do this successfully.