0
I’m facing a problem with an app in Java for Android, the app apparently arrives at a point that consumes excessive server resource, if many users connect in the app reaches the point of taking down the server, the app is in Java integrated with webservice in Laravel.
Below I will post the routine that apparently causes problem by what we detect on the server, since this routine calls the url we detected is consuming excessive resource on the server.
private class UploadDataToServer extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
try {
HttpParams myParams = new BasicHttpParams();
myParams.setParameter("http.useragent", "Apache-HttpClient/UNAVAILABLE (java 1.4)");
myParams.setIntParameter("http.socket.timeout", 60 * 1000);
myParams.setBooleanParameter("http.connection.stalecheck", false);
myParams.setIntParameter("http.connection.timeout", 60 * 1000);
myParams.setBooleanParameter("http.protocol.handle-redirects", false);
myParams.setIntParameter("http.socket.buffer-size", 8192);
//HttpConnectionParams.setConnectionTimeout(myParams, 100000); //100000
//HttpConnectionParams.setSoTimeout(myParams, 100000); //100000
HttpClient httpClient = new DefaultHttpClient(myParams);
ResponseHandler<String> res = new BasicResponseHandler();
HttpPost postMethod = new HttpPost(
AndyConstants.ServiceType.UPDATE_PROVIDER_LOCATION);
// HttpRequest httpRequest = new HttpRequest();
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair(
AndyConstants.Params.ID, id));
nameValuePairs.add(new BasicNameValuePair(
AndyConstants.Params.TOKEN, token));
nameValuePairs.add(new BasicNameValuePair(
AndyConstants.Params.LATITUDE, latitude));
nameValuePairs.add(new BasicNameValuePair(
AndyConstants.Params.LONGITUDE, longitude));
nameValuePairs.add(new BasicNameValuePair(
AndyConstants.Params.BEARING, bearing + ""));
preferenceHelper.putLatitude(Double.parseDouble(latitude));
preferenceHelper.putLongitude(Double.parseDouble(longitude));
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
String response = httpClient.execute(postMethod, res);
// String response = httpRequest.postData(
// AndyConstants.ServiceType.UPDATE_PROVIDER_LOCATION,
// nameValuePairs);
AppLog.Log("TAG", "location send Response:::" + response);
JSONObject jsonObject = new JSONObject(response);
if (jsonObject.getBoolean("success")) {
if (jsonObject.getString("is_active").equals("1"))
preferenceHelper.putIsActive(true);
else
preferenceHelper.putIsActive(false);
}
return response;
} catch (Exception exception) {
exception.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
stopSelf();
}
}
This routine is in the file Locationupdateservice.java, this file sends to the server from time to time the user’s location (Latitude/Longitude).
I would like to count on your help to have at least an idea of what can be done to solve this problem.
If the problem is in server consumption, you need to scan the server. What is the Laravel routine when you receive this call?
– David Dias