This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Android + REST + Spring, How conect to server through WIFI?

 
Roberto Rodriguez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have been learning REST, and all facilities that Spring provide for work with it.

At first, I developed a web application using Spring that work as server to export a service, which consists in return one object by id.
Then I developed a client web application with Spring to consume the service, using RestTemplate, and it worked without problems.

But when I try to do the same that I did in the client in an android application It cant connect to Server.

This is the code:



I also include all permissions in the AndroidManifest.xml,



Then when I run that code, after several minutes waiting, the app throw the Exception:



Then my question is:
Why if I can comunicate with the server since a web application, I can't do it since an android application?
I have the web applications (client and server) running in the same PC, and the android app in my phone, then: Has the WIFI connection anything to do with it?

I will be gratefull by your answer
Regards
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
192.168.1.87 is a private IP address - is it accessible from the Wifi network the device is connected to?
 
Roberto Rodriguez
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your answer,
You are right, that ip address was assigned to my PC by the local router, so it is not public to internet and for that reason my phone doesn't see it,
then, How can I do to my phone see that particular ip address?
or, How may I do the router allow that ip address be accessed for another device through WIFI?
I know that is out of android scope but may be someone have more experience in these issues and might help me.
Any opinion is helpful for me.
Thanks.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The address should be accessible from within the same network - is the router a WLAN router that you can set up to let your device connect to it? If not, then you will need to configure the router to let traffic from whatever Wifi network the device it on through. That could become complicated, because private IP addresses are not generally routeable across networks (for good reasons). It also depends entirely on the setup and capabilities of the router.

Alternatively, run the app on the emulator on your desktop machine - it should have no problems accessing that WS using either the private address or 127.0.0.1.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic