I am trying to encode an Android application that sends some post values ββto a php file hosted on a dedicated server and saves a resoult array
code is
HttpPost httppost; DefaultHttpClient httpclient; httppost = new HttpPost("http://IP/script.php"); HttpParams param = new BasicHttpParams(); param.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); // httppost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false); HttpProtocolParams.setContentCharset(param, "UTF-8"); httpclient = new DefaultHttpClient(param); ResponseHandler <String> res=new BasicResponseHandler(); List<NameValuePair> nameValuePairs; nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("id","1")); nameValuePairs.add(new BasicNameValuePair("api", "1")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); Log.v("1",System.currentTimeMillis()+"");// Log to know the time diff String result= httpclient.execute(httppost, res); Log.v("2",System.currentTimeMillis()+""); // Log to know the time diff
this code takes about 2.5 seconds (on 3G or WiFi) to send a message and get the string βnormalβ from the server, even with good Wi-Fi this time up to 2.2 / 2.0 seconds
I launched a simple sending Ajax script on my computer connected to the Internet via the same phone and 3G, in order to do the same as in the case of the phone, it takes about 300 ms. So what is the same connection, the same action, 2 seconds difference?
/// *** UPDATE
I tried my jquery script again on my computer (with mobile 3G + / HDSPA connection)
the average time response is 250 ms , but always the first request is up to 1.7 seconds , I tried to send messages at intervals of 30 seconds, and I got an average value of 1.5 seconds time, then I tried to send a message at intervals of 2 seconds, the first was 1.41 s and nexts 252ms
here you guys can view the diagram: http://i46.tinypic.com/27zjl8n.jpg
The same cable connection test (standard home DSL) always offers a fixed response time of ~ 170 ms regardless (there are no good arguments here, but IMHO, perhaps the first attempt is a bit higher)
So, there is something (or wrong) that seriously affects mobile connections in the first attempt. Any ideas?