I’m trying to make a get request to a servlet but I keep getting a time out exception, while using the mobile data connection
java.net.SocketException: The operation timed out
When using the phone mobile data connection, I can surf the web on the browser so its not my data bundle, and the code works on the wifi connection no problem.
I tried setting the timeout to something like 1000000 milliseconds but still get the exception, can anyone help me?
here is the code I am using
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 1000000 );
HttpConnectionParams.setSoTimeout(httpParameters, 1000000 );
HttpConnectionParams.setTcpNoDelay(httpParameters, true);
HttpClient httpclient = new DefaultHttpClient(httpParameters);
HttpResponse response = null;
Log.d(TAG, "" + id[0]);
response = httpclient.execute(new HttpGet(
"http://192.168.1.10:8080/serv/request?id=" + id[0]));
Log.d(TAG, response.toString());
Log.d(TAG, "status" + response.getStatusLine());
From your URI (
http://192.168.1.10:8080/serv/request?id=) it looks like you are trying to access server in the local LAN. So if your server is located in the local LAN and if it can not be accessed from the internet then you would not be able to connect to it using the mobile data connection…Where is your server hosted? is your server accessible on internet? You need to have a static IP on your server to access the server using the mobile data connection..