Retrofit throws 'conversion' error for one of the responses - android

I am fetching data using Retrofit,
In a synchronous request, I am getting response with code 200, but when it goes to de-serialize using my model class, it throws an error, problem is that for one input/response it parses the data, while for another input/response (from the same API) it throws CONVERSION type error.
I don't understand what causes a CONVERSION error.
Upon printing stacktrace, I got -
Sample-ProjectErrorHandler: conversion error
03-02 14:35:50.054 17161-17161/com.discover.Sample-Project W/System.err: retrofit.RetrofitError: Please try in few minutes
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: at retrofit.CallbackRunnable.run(CallbackRunnable.java:50)
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: at retrofit.Platform$Android$2$1.run(Platform.java:142)
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: at java.lang.Thread.run(Thread.java:841)
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: Caused by: java.lang.Exception: Please try in few minutes
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: at com.discover.Sample-Project.api.Sample-ProjectErrorHandler.handleError(Sample-ProjectErrorHandler.java:77)
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: at retrofit.CallbackRunnable.run(CallbackRunnable.java:49)
03-02 14:35:50.064 17161-17161/com.discover.Sample-Project W/System.err: ... 4 more
this question

Related

can't load images from url with Picasso

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)

Android N java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

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.

"Trust anchor for certification path not found" when user clears cache

In my app, when the user manually clears the application cache, they will start getting the error "Trust anchor for certification path not found".
My setup is as follows: the app has a hardcoded URL of a central server. This central server will tell the app the URL of the API that it can log into. When connecting to the central server, the app creates a sync account and stores this url as UserData in the sync account.
When the user clears their cache, after logging in, they will start getting this exception, which will persist even when rebooting the device.
However, when they remove the sync account, and log in again through the central server, the problem disappears. This is the code in URLConnectionHelper that triggers the problem and the stacktrace. (My code is com.my.package)
public static InputStream getInputStream(AppUser appUser, String fullpath, Map<String, ?> params, Method method) throws IOException
{
URL url = new URL(fullpath + getQuery(params));
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
if (appUser != null)
conn.setRequestProperty("X-AuthToken", appUser.getToken());
if (method == Method.POST || method == Method.PUT)
conn.setDoOutput(true);
conn.setRequestMethod(method.toString());
conn.connect(); // <-- line 69
return new BufferedInputStream(conn.getInputStream(), 8192);
}
06-01 12:04:52.441 26902-27032/com.my.package W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-01 12:04:52.441 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:409)
06-01 12:04:52.441 26902-27032/com.my.package W/System.err: at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
06-01 12:04:52.441 26902-27032/com.my.package W/System.err: at com.android.okhttp.Connection.connect(Connection.java:107)
06-01 12:04:52.441 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
06-01 12:04:52.441 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
06-01 12:04:52.441 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:161)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.my.package.util.URLConnectionHelper.getInputStream(URLConnectionHelper.java:69)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.my.package.util.URLConnectionHelper.getString(URLConnectionHelper.java:103)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.my.package.util.URLConnectionHelper.getJSONObject(URLConnectionHelper.java:117)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.my.package.task.LoginExistingAccountTask.doInBackground(LoginExistingAccountTask.java:59)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.my.package.task.LoginExistingAccountTask.doInBackground(LoginExistingAccountTask.java:23)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at java.lang.Thread.run(Thread.java:841)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:611)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: ... 19 more
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: ... 24 more
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:409)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.okhttp.Connection.connect(Connection.java:107)
06-01 12:04:52.446 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:161)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.my.package.util.URLConnectionHelper.getInputStream(URLConnectionHelper.java:69)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.my.package.util.URLConnectionHelper.getString(URLConnectionHelper.java:103)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.my.package.util.URLConnectionHelper.getJSONObject(URLConnectionHelper.java:117)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.my.package.task.LoginExistingAccountTask.doInBackground(LoginExistingAccountTask.java:59)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.my.package.task.LoginExistingAccountTask.doInBackground(LoginExistingAccountTask.java:23)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at java.lang.Thread.run(Thread.java:841)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:611)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: ... 19 more
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-01 12:04:52.451 26902-27032/com.my.package W/System.err: ... 24 more

retrofit.RetrofitError: sendto failed: EPIPE (Broken pipe)

I'm using Retrofit 1.9.0 for my RESTclient in android, It get error like i post below:
retrofit.RetrofitError: sendto failed: EPIPE (Broken pipe)
04-03 20:18:51.995 8634-8634/up.tech.opener W/System.err: at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
04-03 20:18:51.995 8634-8634/up.tech.opener W/System.err: at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
04-03 20:18:51.995 8634-8634/up.tech.opener W/System.err: at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
04-03 20:18:51.995 8634-8634/up.tech.opener W/System.err: at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
04-03 20:18:51.995 8634-8634/up.tech.opener W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-03 20:18:51.996 8634-8634/up.tech.opener W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-03 20:18:51.996 8634-8634/up.tech.opener W/System.err: at retrofit.Platform$Android$2$1.run(Platform.java:142)
04-03 20:18:51.996 8634-8634/up.tech.opener W/System.err: at java.lang.Thread.run(Thread.java:838)
04-03 20:18:51.996 8634-8634/up.tech.opener W/System.err: Caused by: java.net.SocketException: sendto failed: EPIPE (Broken pipe)
04-03 20:18:51.997 8634-8634/up.tech.opener W/System.err: at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:550)
04-03 20:18:51.997 8634-8634/up.tech.opener W/System.err: at libcore.io.IoBridge.sendto(IoBridge.java:519)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at java.net.PlainSocketImpl.write(PlainSocketImpl.java:511)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:269)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at java.io.OutputStream.write(OutputStream.java:82)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at libcore.net.http.HttpEngine.writeRequestHeaders(HttpEngine.java:659)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:808)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:293)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:505)
04-03 20:18:51.998 8634-8634/up.tech.opener W/System.err: at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
04-03 20:18:51.999 8634-8634/up.tech.opener W/System.err: at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
04-03 20:18:51.999 8634-8634/up.tech.opener W/System.err: at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
04-03 20:18:51.999 8634-8634/up.tech.opener W/System.err: ... 7 more
Can anyone know how to fixing this please?
Just to make sure that your configuration is correct
check if you have added all the required permissions to your AndroidManifest.xml (EPIPE happens often as a result of missing permissions)
Script might be getting stuck somewhere in the code, hence not posting the response meanwhile server would have closed the socket.
Increasing timeout values
okHttpClient = new OkHttpClient();
okHttpClient.setReadTimeout(60, TimeUnit.SECONDS);
okHttpClient.setConnectTimeout(60, TimeUnit.SECONDS);
Add this on your gradle
compile 'com.squareup.okhttp:okhttp:2.0.0'
Compile 'come.scrap.okhttp:okhttp-urlconnection:2.0.0'
if not set port in retrofit helper , like this : http://172.51.65.62
retforit try to connect to : http://172.51.65.62:80
now if used any port else port number 80 , you will get this error
for fix this error change ip or address like : http://172.51.65.62:8256

GcmPubSub subscribe Invalid appInstanceToken:

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.

Categories

Resources