android-async-http: Unable to resolve host "xxx.xxx.61.116:8087": No address associated with hostname
I’m trying to consume a SOAP service with the version 1.4.9 but I have an error and with the version 1.4.7 works fine.
W/System.err: java.net.UnknownHostException: Unable to resolve host "static-xxx-xxx-61-116.une.net.co": No address associated with hostname
W/System.err: at java.net.InetAddress.lookupHostByName(InetAddress.java:427)
W/System.err: at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
W/System.err: at java.net.InetAddress.getByName(InetAddress.java:305)
W/System.err: at cz.msebera.android.httpclient.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:154)
W/System.err: at cz.msebera.android.httpclient.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(SchemeSocketFactoryAdaptor.java:65)
W/System.err: at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
W/System.err: at cz.msebera.android.httpclient.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:145)
W/System.err: at cz.msebera.android.httpclient.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
W/System.err: at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
W/System.err: at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
W/System.err: at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:860)
W/System.err: at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
W/System.err: at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:146)
W/System.err: at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:177)
W/System.err: at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:106)
W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err: at java.lang.Thread.run(Thread.java:818)
The error happens when the url has a port associated, with not using the port works well. example: This works:
http://xxx.xxx.195.171/wsgenesis/wsgenesis.asmx
This does not work:
http://xxx.xxx.61.116:8087/wsgenesis/wsgenesis.asmx
This is my code:
client = new AsyncHttpClient();
client.setTimeout(20000);
String soapAction = "http://navacom.com.co/Login";
client.addHeader("Content-Type", "text/xml; charset=utf-8");
client.addHeader("SOAPAction", soapAction);
String contentType = "text/xml; charset=utf-8";
StringEntity entity = null;
try {
entity = new StringEntity(body, "utf-8");
entity.setContentType("text/xml; charset=utf-8");
entity.setChunked(true);
} catch (IllegalArgumentException e) {
Log.d("Depuracion", "StringEntity: IllegalArgumentException " + e);
}
String serverUrl = url + "?op=Login";
client.post(mContext, serverUrl, entity, contentType, new AsyncHttpResponseHandler() {
....
....
});
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (1 by maintainers)
@indiefr you need to work for now with the version 1.4.8 from the android-async-http library. To use this library you can add to your gradle file this line:
compile ‘com.loopj.android:android-async-http:1.4.8’
Also you need to download the jar file org.apache.http.legacy.jar and also add this file to your gradle file, just copy that file to your libs folder and then add this line in your gradle file:
compile files(‘libs/org.apache.http.legacy.jar’)
The Header class is from that jar file not from android-async-http library.
I hope this help you.
Lib for classes such as Header[] and BasicClientCookie (deprecated)
Working version
Fixed my issue : No address associated with hostname