• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic