I have a web service written in PHP (runs on LAMP stack) that I use to upload a file and process it.
When I call this from my android app, the server returns error 503.
In Android, if I remove the file upload part and pass other parameters, it works !!!
If I comment all the code, still it gives error. So it looks like for some reason the file upload via Android is not working !!
Note : It was working until last week. Last week I moved my web server to new hosting (different IP) - That's all.
If I test from Chrome Rest Client, it works perfectly fine !!!
Same script on a different server (different domain name and IP) works fine.
What could be the error ? Why does it fail only when I call from Android app !!
Following is the Android code:
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(web_url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
InputStream is = PBAApplication.getInstance().getContext().getContentResolver().openInputStream(fileURI);
InputStreamBody isb = new InputStreamBody(is, fileName);
builder.addPart("type", new StringBody("APPM"));
builder.addPart("file", isb);
httpPost.setEntity(builder.build());
// Execute HTTP Request
HttpResponse response = httpClient.execute(httpPost);
Server error log shows this:
(32)Broken pipe: [client 219.74.158.38:21214] AH01075: Error dispatching request to : (sending stdin)
There are a few things you can do to troubleshoot:
To log all traffic going through HttpClient, use these terminal commands:
Add this to your Application class: