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

Status
Not open for further replies.
SS-2013-02-21_16.08.18.png


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:
B4X:
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).
 

Attachments

  • DynamicIp.bas
    2 KB · Views: 2,858

melamoud

Active Member
Licensed User
Longtime 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...
 

pandi

Member
Licensed User
Longtime User
does anyone has complete sample, I am still confuse how to start it, thanks
 

IslamQabel

Active Member
Licensed User
Longtime 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
 

IslamQabel

Active Member
Licensed User
Longtime 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
 

IslamQabel

Active Member
Licensed User
Longtime 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


 

IslamQabel

Active Member
Licensed User
Longtime 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........
 

IslamQabel

Active Member
Licensed User
Longtime 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
 

techknight

Well-Known Member
Licensed User
Longtime 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.
 
  • Like
Reactions: GIS
Status
Not open for further replies.
Top