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

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

Related

Android can't reach URL using Volley library

Hi I write my app and have many problems but this is really strange.
All connections to mysql by php was working good. Today I everything was ok but suddenly i couldn't reach URL.
Here is the logcat:
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie I/System.out: AsyncTask #8 calls detatch()
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.20 refused
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:248)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:172)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:130)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.executeOriginal(DefaultRequestDirector.java:1337)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:705)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:579)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:503)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:481)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at com.example.dawid.logowanie.JSONParser.makeHttpRequest(JSONParser.java:51)
05-18 19:06:00.310 21093-21353/com.example.dawid.logowanie W/System.err: at com.example.dawid.logowanie.AddBookActivity$CreateNewProduct.doInBackground(AddBookActivity.java:197)
05-18 19:06:00.320 21093-21353/com.example.dawid.logowanie W/System.err: at com.example.dawid.logowanie.AddBookActivity$CreateNewProduct.doInBackground(AddBookActivity.java:156)
05-18 19:06:00.320 21093-21353/com.example.dawid.logowanie W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
05-18 19:06:00.320 21093-21353/com.example.dawid.logowanie W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
05-18 19:06:00.320 21093-21353/com.example.dawid.logowanie W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
05-18 19:06:00.320 21093-21353/com.example.dawid.logowanie W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
05-18 19:06:00.320 21093-21353/com.example.dawid.logowanie W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
05-18 19:06:00.320 21093-21353/com.example.dawid.logowanie W/System.err: at java.lang.Thread.run(Thread.java:818)
05-18 19:06:00.320 21093-21353/com.example.dawid.logowanie W/System.err: Caused by: java.net.ConnectException: failed to connect to /192.168.1.20 (port 80): connect failed: ETIMEDOUT (Connection timed out)
05-18 19:06:00.330 21093-21353/com.example.dawid.logowanie W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:124)
05-18 19:06:00.330 21093-21353/com.example.dawid.logowanie W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
05-18 19:06:00.330 21093-21353/com.example.dawid.logowanie W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:452)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: at java.net.Socket.connect(Socket.java:884)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:124)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:193)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: ... 16 more
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: Caused by: android.system.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: at libcore.io.Posix.connect(Native Method)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: at libcore.io.IoBridge.connectErrno(IoBridge.java:137)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:122)
05-18 19:06:00.340 21093-21353/com.example.dawid.logowanie W/System.err: ... 21 more
In other cases pDialog shows I wait and wait and get nothing only:
05-18 19:10:05.850 27036-27036/com.example.dawid.logowanie E/RegisterActivity: Blad Rejestracji: null
05-18 19:10:05.900 27036-27036/com.example.dawid.logowanie D/ViewRootImpl: #3 mView = null
05-18 19:10:05.920 27036-27036/com.example.dawid.logowanie D/Volley: [1] Request.finish: 7625 ms: [ ] http://192.168.1.20/android_login_api/Check.php 0x676929da NORMAL 1
05-18 19:10:05.920 27036-27036/com.example.dawid.logowanie D/ViewRootImpl: #1 mView = android.widget.LinearLayout{4c07063 V.E...... ......I. 0,0-0,0 #102039d android:id/toast_layout_root}
05-18 19:10:05.930 27036-27036/com.example.dawid.logowanie E/ViewRootImpl: sendUserActionEvent() mView == null
Like I said earlier everything was working fine but suddenly stopped. I restarted my phone many times, I change phone and nothing. I did Invalidate Caches/Restart but still have the problem.
Solved! It was because of my home wifi network. I turned on hotspot on another phone and connect my laptop and phone to test and worked. I still don't understand how earlier everything was working on my home wifi and suddenly stopped.
Someone know how is it possible?

error javax.net.ssl.SSLPeerUnverifiedException: No peer certificate and SSLNullSession.java:104

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.

Connection refused in Android M while trying httprequest from Android Service

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!

Connection to IP is refused when trying to connect from android application

I am trying to connect my android app with server which is running in same PC,ip is 192.168.1.129,and tomcat port is 8081,getting below issue,Can any one help me to resolve this?
10-07 15:51:45.672 29710-5937/com.net.app W/System.err: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.129:8081 refused
10-07 15:51:45.673 29710-5937/com.net.app W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:188)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:169)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:124)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:379)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:580)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:503)
10-07 15:51:45.674 29710-5937/com.net.app W/System.err: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:481)
10-07 15:51:45.679 29710-5937/com.net.app W/System.err: at com.chronicwatch.app.utils.WebRequest.post(WebRequest.java:72)
10-07 15:51:45.679 29710-5937/com.net.app W/System.err: at com.chronicwatch.app.utils.WebRequest.loadDataFromNetwork(WebRequest.java:54)
10-07 15:51:45.679 29710-5937/com.net.app W/System.err: at com.octo.android.robospice.request.CachedSpiceRequest.loadDataFromNetwork(CachedSpiceRequest.java:48)
10-07 15:51:45.680 29710-5937/com.net.app W/System.err: at com.octo.android.robospice.request.DefaultRequestRunner.processRequest(DefaultRequestRunner.java:150)
10-07 15:51:45.680 29710-5937/com.net.app W/System.err: at com.octo.android.robospice.request.DefaultRequestRunner$1.run(DefaultRequestRunner.java:217)
10-07 15:51:45.680 29710-5937/com.net.app W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
10-07 15:51:45.680 29710-5937/com.net.app W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-07 15:51:45.681 29710-5937/com.net.app W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-07 15:51:45.681 29710-5937/com.net.app W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-07 15:51:45.681 29710-5937/com.net.app W/System.err: at java.lang.Thread.run(Thread.java:818)
10-07 15:51:45.681 29710-5937/com.net.app W/System.err: Caused by: java.net.ConnectException: failed to connect to /192.168.1.129 (port 8081) after 15000ms: isConnected failed: EHOSTUNREACH (No route to host)
10-07 15:51:45.682 29710-5937/com.net.app W/System.err: at libcore.io.IoBridge.isConnected(IoBridge.java:238)
10-07 15:51:45.682 29710-5937/com.net.app W/System.err: at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:122)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err: at java.net.Socket.connect(Socket.java:882)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err: at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:124)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:149)
10-07 15:51:45.685 29710-5937/com.net.app W/System.err: ... 16 more
10-07 15:51:45.685 29710-5937/com.net.app W/System.err: Caused by: android.system.ErrnoException: isConnected failed: EHOSTUNREACH (No route to host)
10-07 15:51:45.686 29710-5937/com.net.app W/System.err: at libcore.io.IoBridge.isConnected(IoBridge.java:223)
10-07 15:51:45.686 29710-5937/com.net.app W/System.err: ... 23 more
There can be two problems. First the firewall can prevent access. Switch it off for a test. Second: Maybe Tomcat is bound to localhost/127.0.0.1 only. Have a check in its settings.
Fixed,My public IP of my PC is different,Public IP of android phone is different(connected to another wi-fi),But both should be same

"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

Categories

Resources