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.
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.
Related
I'm facing this error javax.net.ssl.SSLPeerUnverifiedException: No peer certificate on android version lower than Marshmallow when I use https to connect the server and I'm getting this exception:
03-27 16:15:04.481 23391-23469/com.intellinects.app W/System.err: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
03-27 16:15:04.495 23391-23469/com.intellinects.app W/System.err: at com.android.org.conscrypt.SSLNullSession.getPeerCertificates(SSLNullSession.java:104)
03-27 16:15:04.495 23391-23469/com.intellinects.app W/System.err: at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
03-27 16:15:04.495 23391-23469/com.intellinects.app W/System.err: at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388)
03-27 16:15:04.495 23391-23469/com.intellinects.app W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165)
03-27 16:15:04.495 23391-23469/com.intellinects.app W/System.err: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-27 16:15:04.495 23391-23469/com.intellinects.app W/System.err: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-27 16:15:04.495 23391-23469/com.intellinects.app W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
03-27 16:15:04.495 23391-23469/com.intellinects.app W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at com.intellinects.app.Network.executeService(Network.java:77)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at com.intellinects.app.Network.checkSecureConnection(Network.java:180)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at com.intellinects.app.Network.get(Network.java:124)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at com.intellinects.app.SplashActivity$CheckURL.doInBackground(SplashActivity.java:144)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at com.intellinects.app.SplashActivity$CheckURL.doInBackground(SplashActivity.java:127)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
03-27 16:15:04.496 23391-23469/com.intellinects.app W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-27 16:15:04.497 23391-23469/com.intellinects.app W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-27 16:15:04.497 23391-23469/com.intellinects.app W/System.err: at java.lang.Thread.run(Thread.java:818)
The server you connected to doesn't have a great SSL certificate. A quick search to StackOverflow forwarded me to this great question and answers: Safely fixing: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
The server you are trying to connect is not authorized. You will have to do SSL pinning, download the SSL Certificate signed by any CA.
IOException
01-11 18:28:25.304 W/System.err: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.42 refused
01-11 18:28:25.306 W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:193)
01-11 18:28:25.306 W/System.err: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:169)
01-11 18:28:25.306 W/System.err: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:124)
01-11 18:28:25.306 W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:370)
01-11 18:28:25.306 W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:560)
01-11 18:28:25.306 W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:492)
01-11 18:28:25.307 W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:470)
01-11 18:28:25.307 W/System.err: at com.aceuat.sms.ACESMSGService.connectServerTeachr(ACESMSGService.java:213)
01-11 18:28:25.307 W/System.err: at com.aceuat.sms.ACESMSGService$1$1.run(ACESMSGService.java:103)
01-11 18:28:25.307 W/System.err: at java.lang.Thread.run(Thread.java:818)
01-11 18:28:25.307 W/System.err: Caused by: java.net.ConnectException: socket failed: EACCES (Permission denied)
01-11 18:28:25.307 W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
01-11 18:28:25.307 W/System.err: ... 9 more
01-11 18:28:25.307 W/System.err: Caused by: java.net.SocketException: socket failed: EACCES (Permission denied)
01-11 18:28:25.313 W/System.err: at libcore.io.IoBridge.socket(IoBridge.java:619)
01-11 18:28:25.313 W/System.err: at java.net.PlainSocketImpl.create(PlainSocketImpl.java:198)
01-11 18:28:25.314 W/System.err: at java.net.Socket.checkOpenAndCreate(Socket.java:689)
01-11 18:28:25.314 W/System.err: at java.net.Socket.connect(Socket.java:849)
01-11 18:28:25.314 W/System.err: at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:124)
01-11 18:28:25.314 W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:149)
01-11 18:28:25.314 W/System.err: ... 9 more
01-11 18:28:25.314 W/System.err: Caused by: android.system.ErrnoException: socket failed: EACCES (Permission denied)
01-11 18:28:25.314 W/System.err: at libcore.io.Posix.socket(Native Method)
01-11 18:28:25.314 W/System.err: at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:282)
01-11 18:28:25.314 W/System.err: at libcore.io.IoBridge.socket(IoBridge.java:604)
01-11 18:28:25.314 W/System.err: ... 14 more
01-11 18:28:40.280 I/ACES: Service is still running
Its Working fine in android lower versions.
As the Problem shows: You need to add internet access permission in the app.
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET" />
<application ...
</manifest>
And at last when app asks for internet access in popup allow the app to use internet!
i'm using Picasso to download images into a listview in my android app.
it's working like a charm except when running on Kitkat environment.
My layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ImageView
android:id="#+id/articleimage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="5dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:layout_alignParentTop="true"
/>
</RelativeLayout>
My logs
08-11 06:30:19.406 28898-28898/com.s W/System.err: com.squareup.picasso.Downloader$ResponseException: 404 Not Found
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.UrlConnectionDownloader.load(UrlConnectionDownloader.java:96)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.NetworkRequestHandler.load(NetworkRequestHandler.java:47)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:206)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at java.lang.Thread.run(Thread.java:841)
08-11 06:30:19.406 28898-28898/com.s W/System.err: at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)
my config
compileSdkVersion 23
buildToolsVersion '23.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
using ImageLoader i get an error in downloading the images
http://url/uploads/Vous-ĂȘtes-cerveau-droit-ou-cerveau-gauche-300x160.jpg
08-15 10:05:09.042 1915-2474/com.s W/System.err: java.io.FileNotFoundException: http://url/uploads/Vous-ĂȘtes-cerveau-droit-ou-cerveau-gauche-300x160.jpg
08-15 10:05:09.042 1915-2474/com.s W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.net.URL.openStream(URL.java:470)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at com.s.ArticleActivity$DownloadImageTask.doInBackground(ArticleActivity.java:446)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at com.s.ArticleActivity$DownloadImageTask.doInBackground(ArticleActivity.java:436)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
08-15 10:05:09.042 1915-2474/com.s W/System.err: at java.lang.Thread.run(Thread.java:841)
In my application i use a self signed certificate to connect over https. The application works perfectly fine when the compilesdk is set to < 24, however when the compilesdk is set to 24 my application fails to connect to the server over https and throws the following exception:
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:192)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:149)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.io.RealConnection.connect(RealConnection.java:112)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:184)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call.getResponse(Call.java:286)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.worklight.wlclient.CertificatePinningInterceptor.intercept(CertificatePinningInterceptor.java:20)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:232)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.worklight.wlclient.OkHttpInterceptor.intercept(OkHttpInterceptor.java:145)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:232)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.squareup.okhttp.Call.execute(Call.java:80)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at com.worklight.wlclient.WLRequestSender.run(WLRequestSender.java:49)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
07-27 14:35:52.927 11424-11956/com.test.Push W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at java.lang.Thread.run(Thread.java:761)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:549)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:401)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:375)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:304)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:178)
07-27 14:35:52.928 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:596)
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: ... 20 more
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
07-27 14:35:52.929 11424-11956/com.test.Push W/System.err: ... 30 more
I followed the steps mentioned here https://developer.android.com/preview/features/security-config.html, however my app still fails to connect to the server over https. My network_security_config.xml is as below:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config>
<domain includeSubdomains="true">test.abc.com</domain>
<trust-anchors>
<certificates src="#raw/ca_norton"/>
</trust-anchors>
</domain-config>
</network-security-config>
In my AndroidManifest.xml included the following under the application tag
<meta-data android:name="android.security.net.config"
android:resource="#xml/network_security_config" />
ca_norton.crt is also copied into the raw folder. Am i missing something here? Thanks in advance.
The correct way to specify a Network Security Config in your manifest is:
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="#xml/network_security_config"
... >
...
</application>
</manifest>
See https://developer.android.com/preview/features/security-config.html#manifest. The meta-data approach was only present in the early N previews and is no longer supported.
i'm recently tried new TOPICs API of Google Cloud Messaging Service. but i always got the error Invalid appInstanceToken:
here is the logcat
java.lang.IllegalArgumentException: Invalid appInstanceToken:
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at com.google.android.gms.gcm.GcmPubSub.subscribe(Unknown Source)
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at com.SimDetail.MainActivity$3.doInBackground(MainActivity.java:265)
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at com.SimDetail.MainActivity$3.doInBackground(MainActivity.java:255)
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:292)
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
11-10 22:28:34.674 15742-15983/com.SimDetail W/System.err: at java.lang.Thread.run(Thread.java:818)
can anyone tell me what i'm doing wrong?
Thanks.
Solved. :)
The GCM Token should be obtain vie new
InstanceID API.
otherwise it throws invalid instance token.
it is not valid with `
GCM.register()
although it receives PUSH but can not subscribe.