Android Tutorial No-IP Android client - Access your device over the internet

Discussion in 'Tutorials & Examples' started by Erel, Feb 21, 2013.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    [​IMG]

    The following solution allows you to access your Android device over the internet. The device must be connected to a local network (with internet access) and configured properly.

    You can use this solution together with HttpServer library to turn an unused Android device to a Http Server.

    There are several challenges which we must overcome to get it working:
    1. The local network public IP (wan IP) is dynamic. It changes from time to time.
    2. The router needs to be configured to forward incoming connections to the device.

    The DynamicIp service module overcomes the first challenge.
    It is a simple No-IP updater client: Free Dynamic DNS - Managed DNS - Managed Email - Domain Registration - No-IP
    No-IP is a free service that allows you to map a no-ip subdomain to your IP address. The updater is responsible for updating the IP. Every 30 minutes it checks whether the public IP has changed with another free web service: ExIp.Org - Home
    If the IP address has changed then it updates the No-IP web service.

    In order to use this service you should create a free account and pass the host, username and password to DynamicIp service:
    Code:
    If FirstTime Then
       
    Dim ni As NoIpValues
       ni.Host = 
    "zzzzz.no-ip.org"
       ni.Username = 
    "yyyyy"
       ni.Password = 
    "xxxxx"
       CallSubDelayed2(DynamicIp, 
    "Start", ni)
    End If
    You only need to start it once. It uses an internal timer to periodically check the IP address.

    The second task requires you to configure your router:
    1. The router should assign your device (based on the MAC address) a static local IP address.
    2. The router should forward incoming connections on the relevant port to the device IP address.

    There are many online tutorials about these tasks (such as: Free Help Forwarding Ports - PortForward.com).

    Note that you can also use raw sockets (Network library) though it will be simpler to use HttpServer in most cases.

    The DynamicIp service is attached. It depends on HttpUtils2 code modules (which depends on Http and StringUtils libraries).
     

    Attached Files:

    Beja, Jerez, DavideV and 1 other person like this.
  2. melamoud

    melamoud Active Member Licensed User

    Just a note.
    No-ip is great I'm working with it for 5 or so years just note that once a month you need to reactivate the account or pay a fee.
    Or they will shutdown the service.

    Make sure the emails for reactivation does not get moved to spam folder...
     
  3. Gabino A. de la Gala

    Gabino A. de la Gala Active Member Licensed User

    ExIp.Org - Home is out of service.

    Anybody knows something similar?

    Thanks.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. Gabino A. de la Gala

    Gabino A. de la Gala Active Member Licensed User

    Thanks Erel for your answer.

    It's working with:

    Code:
    job.Download("http://www.icanhazip.com/")
     
    Sytek and ellpopeb4a like this.
  6. pandi

    pandi Member Licensed User

    does anyone has complete sample, I am still confuse how to start it, thanks
     
  7. IslamQabel

    IslamQabel Active Member Licensed User

    Thanks for the great tutorial.....now i think if users can not deal with free sites because may be after long time the user have to purchase .... to trace WAN IP, it is easily to purchase an static WAN IP from the Internet Service Provider and i think the price of IP is cheap....

    I would like to ask important questions:

    1. First of all, i make web server and has html page in files folder, this page have some buttons with hyperlinks... to access this page i should type in my PC (located in the same LAN with my mobile)web browser 192.168.1.100:5555.....when i type this, the page appears.
    2. when you click on a button, it performs some tasks in the activity module (for example: button 1 has hyperlink http://192.168.1.100:5555/A).....when pressing that button a toast message appears ( button 1 pressed)...button2 ...has http://IP:PORT/B.....etc
    3. Now, if i know my WAN IP say...200.120.230.89, and i make successful "NAT" in my router, how to access my web server?
    • If i typed in any user web browser outside this LAN...http://200.120.230.89:5555....the web page of buttons will appears?
    • If the answer yes, when i click on button1, will the server understand the command as "/A" regards the IP (LAN or WAN)? and the toast message appears?
    Thanks
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    You just need to use the host name instead of the ip address. See the screenshot in the first post.
     
    roxor likes this.
  9. IslamQabel

    IslamQabel Active Member Licensed User

    In the above post, the host name is "basic4android.no-ip.org" .....right?....in my case i just build htttp server on my mobile which is connected to the router and has static Local IP address ....and Desktop on the same LAN....where is my Host? what is the name of it????

    so....what do you think about what i said in point#3 in my last post right or wrong? .....i am still confused...
    thanks
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Yes.

    Are you looking for your external ip address? You can find it here: http://www.whatismyip.com/

    With the external ip address you can connect to your device (assuming that the router is configured properly).
     
  11. IslamQabel

    IslamQabel Active Member Licensed User

    so based on what you said......refer to point#3 in my post.....
    • If i typed in any user web browser outside this LAN...http://200.120.230.89:5555....the web page of buttons will appears?
    • If the answer yes, when i click on button1, will the server understand the command as "/A" regards the IP (LAN or WAN)? and the toast message appears?
    that is All what i need to know....
    Thanks


     
  12. Erel

    Erel Administrator Staff Member Licensed User

    (please don't use all bold text)

    1. Yes.
    2. Yes.
     
  13. IslamQabel

    IslamQabel Active Member Licensed User

    I tested it and it works good...but what i noticed that i should replace the Local IP address with the external IP in the html page code......because when i access the web page from anywhere....click on any button has no effect because it has the Local IP Hyperlink but when i typed in the web browser "ExternalIP:5555/A".....it works....

    Apologize for bold text writing........
     
    Beja likes this.
  14. Erel

    Erel Administrator Staff Member Licensed User

    The best solution is to use relative URLs in your html.
     
  15. IslamQabel

    IslamQabel Active Member Licensed User

    how to do that?.......i can not understand....please clarify...
     
  16. IslamQabel

    IslamQabel Active Member Licensed User

    The Absolute URL is "http://200.120.230.89:5555".....which open the main page for remote access, its name is "test2.html" stored in Files folder in my app.....the local IP is 192.168.1.100 and after configuring router..they are equal.. so do you mean that i should replace this hyperlink "http://192.168.1.100:5555/A" <a href="http://192.168.1.100:5555/A">......</a> by <a href="A">...</a>..in html code???? do you think that web server will understand this???
    thanks
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    Yes. You should use relative urls.
     
  18. IslamQabel

    IslamQabel Active Member Licensed User

    It tested on locally in the LAN, i will tested it on the internet
    thanks
     
  19. BarryW

    BarryW Active Member Licensed User

    Any link of hosts that i can use for this? Tnx...
     
  20. techknight

    techknight Well-Known Member Licensed User

    Sorry to post to an old thread, But I just want to make everyone aware that anyone using standard data service is most likely been moved to whats called a "Carrier Grade NAT" Meaning your external IP is now different than the WAN IP assigned to your phone. Verizon was the first to start that. I am sure everyone else has moved. Of course you can still pay for a Static IP and get around the NAT blocking, but unfortunately at least on Verizon, you cannot access your phone as a server from the internet anymore because of the NAT blocking.

    My Home ISP just started this same crap. I had to sub to PureVPN to get around it.
     
    GIS likes this.
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice