Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8329361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:45:28+00:00 2026-06-09T01:45:28+00:00

I have an Android application that communicates with a server on a hosting provider.

  • 0

I have an Android application that communicates with a server on a hosting provider.
This application sends an http request php script retrieves the request and performs operations in the database.
I changed the database and I have adapted the program, and now I get an error at the server: ” Your request timed out. Please retry the request.”

When I execute the command http in a browser like firefox or chrome, the command is executed correctly, by against error occurs when I execute the code.

This is not the script or the http request, as a result I do not see at all where that might come. Can you help me? Thank you very much.

There the Android code:

public class ConnexionSQL extends AsyncTask<Object,Void, ArrayList<String[]> > {


private static ArrayList<String[]> lesMessagesEtDate;
private String mydataFromHMI;
private String myFichierPHPbase;
private ProgressDialog pd;
private String[] splitData;
private boolean isProblemConnexion;

public ConnexionSQL(Activity activity) {

    pd = new ProgressDialog(activity);
    lesMessagesEtDate = new ArrayList<String[]>();
    mydataFromHMI = "";
    myFichierPHPbase="";
    isProblemConnexion = false;
}


protected ArrayList<String[]> doInBackground(Object... parametres) {
    Object[] tabArg = parametres;
    ArrayList<String[]>  messagesDateEtLocalisation = new ArrayList<String[]>();
    pd.show();

     if (((String)tabArg[3]).equalsIgnoreCase("insert")){

         insertIntoBD((String)tabArg[0], (Context)tabArg[1], (String)tabArg[2]);

     }else if(((String)tabArg[3]).equalsIgnoreCase("connect")){

         messagesDateEtLocalisation = ConnexionBD((String)tabArg[0], (Context)tabArg[1], (String)tabArg[2]);
     }
    return messagesDateEtLocalisation;
}


protected void onPreExecute() {
    pd.setMessage("Chargement en cours");
    pd.show();
}


protected void onProgressUpdate(){
    pd.setMessage("Chargement en cours");
    pd.show();
}

protected void onPostExecute(ArrayList<String[]> array)
{
    pd.setMessage("Le chargement se termine");
    pd.dismiss();     

}

public void insertIntoBD(String dataFromHMI, Context context, String FichierPHPbase){


    mydataFromHMI = dataFromHMI;
    myFichierPHPbase = FichierPHPbase;



    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

    try{
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        HttpProtocolParams.setUseExpectContinue(params, false);  
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 10000);
        ConnManagerParams.setMaxTotalConnections(params, 1000);
        ConnManagerParams.setTimeout(params, 30000);

        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http",PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https",PlainSocketFactory.getSocketFactory(), 80));
        ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params, registry);
        HttpClient httpclient = new DefaultHttpClient(manager, params);

        HttpPost httppost = new HttpPost("http://routeslibre.fr/"+ myFichierPHPbase + "?variable=" + mydataFromHMI);
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        httpclient.execute(httppost);


    }
    catch(Exception e){
        Log.i("taghttppost",""+e.toString());
        isProblemConnexion = true;
    }

}



public ArrayList<String[]> ConnexionBD(String dataFromHMI, Context context,String FichierPHPbase) {

    mydataFromHMI = dataFromHMI;
    myFichierPHPbase = FichierPHPbase;

    String result = null;
    InputStream is = null;
    JSONObject json_data=null;
    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

    try{
        //commandes httpClient

        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
        HttpProtocolParams.setUseExpectContinue(params, false);  
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 10000);
        ConnManagerParams.setMaxTotalConnections(params, 1000);
        ConnManagerParams.setTimeout(params, 30000);

        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http",PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https",PlainSocketFactory.getSocketFactory(), 80));
        ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(params, registry);


        HttpClient httpclient = new DefaultHttpClient(manager, params);             

        GestionStrings gestionString = new GestionStrings();
        splitData = mydataFromHMI.split(";;;");
        mydataFromHMI = gestionString.blancTraitement(splitData[0]) 
                + ";;;" 
                + gestionString.blancTraitement(splitData[1]) 
                + ";;;";

        HttpPost httppost = new HttpPost("http://routeslibre.fr/"+ myFichierPHPbase + "?variable=" + mydataFromHMI);
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
    }
    catch(Exception e){
        Log.i("taghttppost",""+e.toString());
        isProblemConnexion = true;
    }


    //conversion de la réponse en chaine de caractère
    try
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));

        StringBuilder sb  = new StringBuilder();

        String line = null;

        while ((line = reader.readLine()) != null) 
        {
            sb.append(line + "\n");
        }

        is.close();

        result = sb.toString();
        if (result.startsWith("<html>"))
        {
            isProblemConnexion = true;
        }
    }
    catch(Exception e)
    {
        Log.i("tagconvertstr",""+e.toString());
        isProblemConnexion = true;
    }
    //recuperation des donnees json
    try{
        JSONArray jArray = new JSONArray(result);

        for(int i=0;i<jArray.length();i++)
        {

            json_data = jArray.getJSONObject(i);
            String[] messageEtDate = new String[2];
            messageEtDate[0] = json_data.getString("message");
            messageEtDate[1] = json_data.getString("date");
            lesMessagesEtDate.add(messageEtDate);


        }
        //setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, lesMessages));
    }
    catch(JSONException e){
        Log.i("tagjsonexp",""+e.toString());
        isProblemConnexion = true;
    } catch (ParseException e) {
        Log.i("tagjsonpars",""+e.toString());
        isProblemConnexion = true;
    }
    if (isProblemConnexion){

        lesMessagesEtDate = new ArrayList<String[]>();
        lesMessagesEtDate.add(new String[]{"connexion_error_1234"});
        isProblemConnexion = false;
    }
    return lesMessagesEtDate;
}

}

There php script code:

$base = mysql_connect ('sql31.free-h.org:3306', '*****', '******'); 
mysql_select_db ('routeslibre', $base) ;  
$variable = $_GET['variable'];
$first_token  = strtok($variable, ";;;");
$second_token = strtok(";;;");
$req =mysql_query("SELECT message, date from routeslibre.routeslibre where departement='$first_token' AND      voie='$second_token' ORDER BY date");
$output=array();
while ($row=mysql_fetch_array($req)) {    
$output[]=$row;    
} 
//on encode en JSON 
print(json_encode($output));
mysql_free_result ($req);

When I stop the debugger on the line “is.close ();” value “db” is equals to “<html> Your request timed out. Please retry the request “

If you do not mind, can you just give me a technique, a way to find the error?

I put this line in the code :
int test = response.getStatusLine().getStatusCode();
and the test value is 408 so (as described in a web site) its mean i have an error in my hosting provider. But why when i put the http request, retreived from the code: value of http://routeslibre.fr/"+ myFichierPHPbase + "?variable=" + mydataFromHMI and when i put it in a web client as chrome or firefox, my php script work very find… i do not understand…. ???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:45:29+00:00Added an answer on June 9, 2026 at 1:45 am

    I found a solution, i loop over the execute code until i have a request (status retreived from the server is equal to 200) or, if the request does not provide any result an error is launch.
    Here there is my solution :

            String httpRequest = new String("http://routeslibre.fr/"+ myFichierPHPbase + "?variable=" + mydataFromHMI);
            HttpPost request = new HttpPost(httpRequest); 
            HttpParams httpParameters = new BasicHttpParams();
            HttpProtocolParams.setVersion(httpParameters, HttpVersion.HTTP_1_1);
            HttpProtocolParams.setContentCharset(httpParameters, HTTP.UTF_8);
    
            DefaultHttpClient httpclient = new DefaultHttpClient(httpParameters);
    
            HttpResponse response = null;
            for(int i= 0; i < 30; i++){
                response = httpclient.execute(request);
                if (response.getStatusLine().getStatusCode() == 200){
                    break;
                }else if (i == 29){
                    
                    //ERROR CODE
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this android application that requires to load data from a remote server
I have an Android application that connects and communicates with a server. Originally the
I have written an application for Android. the main part being that it communicates
I have an Android application that connects to Facebook to request authorization of an
I am developing a Android application which communicates with a PHP server via JSON.
So, I have an application that communicates with a server quite frequently. I have
I have an application that communicates to server. I want my application to READ
I am writing an application that communicates using sockets. I have a server running
I'm developing an Android 2.3.3 application with a service. I have this inside that
I have an android application that launches a child Activity under certain situations. Both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.