Android client code:
URL url = new URL("http://192.168.0.106:8080/RestApp2_war_exploded/rs/hello"); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("GET"); urlConnection.setConnectTimeout(5000); Log.e("TAG", "metka 1"); urlConnection.connect(); Log.e("TAG", "metka 2"); //здесь обрабтчик catch (IOException e) { Log.e("TAG", "Io exc " + e); } The server is in Java and returns a regular string. In the browser works.
The code does not reach the second label. Log:
03-15 17: 59: 18.122 23717-23934 / com.ka.restapp1 E / TAG: metka 1
03-15 17: 59: 23.240 23717-23934 / com.ka.restapp1 E / TAG: Io exc java.net.SocketTimeoutException: failed to connect to /192.168.0.106 (port 8080) after 5000ms
I'm testing on a real machine. Am I quoting host 192.168.0.106 correctly?
And another small question: what am I doing now and is called a RESTful client?
ERR_ADDRESS_UNREACHABLE- T. Kudaibergen