API Link : http://www.familybuds.com/storegrunt-new/api_home/validate_step_one/platform/1
POST parameter : store_name = "abc"
the code is on GoDaddy Server
This api was working fine till 25July, but suddenly it stopped working from 26th morning on Android APP. The same api is working fine on iPhone APP.
Android Code:
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 10000);
HttpConnectionParams.setSoTimeout(httpParameters, 10000+12000);
DefaultHttpClient client = new DefaultHttpClient(httpParameters);
HttpPost httppost = new HttpPost(url);
HttpResponse response;
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
client.addRequestInterceptor(new HttpRequestInterceptor() {
@Override
public void process(HttpRequest request, HttpContext context)
throws HttpException, IOException {
// TODO Auto-generated method stub
if (!request.containsHeader("Accept-Encoding")) {
request.addHeader("Accept-Encoding", "gzip");
}
}
});
client.addResponseInterceptor(new HttpResponseInterceptor() {
public void process(
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
HttpEntity entity = response.getEntity();
if (entity != null) {
Header ceheader = entity.getContentEncoding();
if (ceheader != null) {
HeaderElement[] codecs = ceheader.getElements();
for (int i = 0; i < codecs.length; i++) {
if (codecs[i].getName().equalsIgnoreCase("gzip")) {
response.setEntity(
new GzipDecompressingEntity(response.getEntity()));
return;
}
}
}
}
}
});
// Log.d(TAG, "Executing request: "+ methodToString(mMethod) +": "+ mUri.toString());
response = client.execute(httppost);
Stack trace(Log) for android:
07-26 16:24:28.031: W/System.err(13642): org.apache.http.NoHttpResponseException: The target server failed to respond
07-26 16:24:28.089: W/System.err(13642): at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:85)
07-26 16:24:28.097: W/System.err(13642): at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174)
07-26 16:24:28.097: W/System.err(13642): at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:179)
07-26 16:24:28.101: W/System.err(13642): at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
07-26 16:24:28.105: W/System.err(13642): at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
07-26 16:24:28.105: W/System.err(13642): at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
07-26 16:24:28.105: W/System.err(13642): at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
07-26 16:24:28.105: W/System.err(13642): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:421)
07-26 16:24:28.109: W/System.err(13642): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
07-26 16:24:28.113: W/System.err(13642): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
07-26 16:24:28.113: W/System.err(13642): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
07-26 16:24:28.117: W/System.err(13642): at com.webhelper.WebApiRequest.performJSon(WebApiRequest.java:111)
07-26 16:24:28.121: W/System.err(13642): at com.webhelper.HttpHelper.doInBackground(HttpHelper.java:171)
07-26 16:24:28.121: W/System.err(13642): at com.webhelper.HttpHelper.doInBackground(HttpHelper.java:1)
07-26 16:24:28.124: W/System.err(13642): at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-26 16:24:28.124: W/System.err(13642): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
07-26 16:24:28.128: W/System.err(13642): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-26 16:24:28.128: W/System.err(13642): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-26 16:24:28.128: W/System.err(13642): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-26 16:24:28.132: W/System.err(13642): at java.lang.Thread.run(Thread.java:1019)
Have tried out solution from : Https connection Android but with no luck..
I tried putting the same server code on Amazon EC2 Server.. and API worked fine with android and iPhone APP.
Can anyone help, what may be the reason for sudden non-working of Android app for communicating with server(API) on GoDaddy
Try replacing above code with this
This solution worked for me....