Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Issue:

If the android app is running alone on one device connected to a router we don't have any issues.

If we try to run the same android app on multiple devices connected to the same router. The app runs poor or we get the exception: HttpHostConnectException: Connection refused.

Seems like something is jamming the connection, when two apps are connected to one router.

We have recreated this issues on Godaddy and Ipage hosting. Seems to be worse when using https over http.
Hosting: Godaddy (also recreated on IPage)
Database: MySQL
Web service files: PHP
App: Android

Sometimes we get the exception but most of the time the connection is slow.

HttpClient client = HttpsClient
.getHttpsClient(new DefaultHttpClient());
HttpPost post = new HttpPost(Constant.URL_LOGIN);
List<namevaluepair> pairs = new ArrayList<namevaluepair>();
pairs.add(new BasicNameValuePair("username", arg0[0]));
pairs.add(new BasicNameValuePair("password", arg0[1]));
try {
post.setEntity(new UrlEncodedFormEntity(pairs));
HttpResponse response = client.execute(post);
InputStream input = response.getEntity().getContent();
BufferedReader streamReader = new BufferedReader(
new InputStreamReader(input, "UTF-8"));
StringBuilder responseStrBuilder = new StringBuilder();
String inputStr;
while ((inputStr = streamReader.readLine()) != null)
responseStrBuilder.append(inputStr);
result = responseStrBuilder.toString();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Thanks in advance!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900