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?

  • Comes from a computer or mobile browser? If the computer and the mobile device are on the same network, the ip-address is correct, then it may be that the firewall on the computer is blocking port 8080 - mexes_s
  • computer browser. From the browser mob. device displays error ERR_ADDRESS_UNREACHABLE - T. Kudaibergen
  • Thanks a lot, it's in the firewall. Tell me, is this a REST client? - T. Kudaibergen

1 answer 1

As described above, it is impossible to say for sure whether you have Rest or not.

Do you follow the basic principles of Rest:

  1. Explicit use of HTTP methods.
  2. Failure state.
  3. Provide a URI similar to the directory structure.
  4. Transferring data to XML, JavaScript Object Notation (JSON) or in both formats?

Good article for familiarization: https://www.ibm.com/developerworks/ru/library/ws-restfu/