Android Question HttpServer internet access

Tim_Pennard

Member
Licensed User
Hi,
I’d like to start a new discussion on how to access an Android device (that is running HttpServer) from the internet.

Initially I’m just trying to use a dynamic external IP address. I think step 2 would then to be to keep checking that IP to see if it changes (or purchase a static IP from my ISP). So far I have Httpserver running successfully on my local network, I’ve attempted to forward a port on my router and have a static IP on the Android device, but am not sure of the next steps.

There is some background on previous threads. https://www.b4x.com/android/forum/t...t-access-your-device-over-the-internet.26611/

It would be great if people can share their experience of doing this.
 

josejad

Expert
Licensed User
Longtime User
Hi:

I don't have any Android device running an HttpServer, but I think you're asking about the general process of redirect a port from your router to a local network device.
Have you look if your router have some embedded dynamic client? Some of them have it, then you just had to register in, and configure the account in the router.
If your router haven't it, you can use for example no-ip.com, they have a computer client you can run from any of your computers in the network, to update your ip.
Then you have to redirect some port from your router to your android device (test you can access your android device from local network first to confirm there's no problem with it). I'm sure you can find the way of doing this searching google something like "redirect port <your-router-model>"

Note that, as you say in the post you've linked, probably you can't reach your public ip from your network because of your router... this need some configuration in your router. So try reach your public ip from some computer out of your local network, or with a mobile connection.
 
Last edited:
Upvote 0

KMatle

Expert
Licensed User
Longtime User
I just played arround with it (for a gps tracker to reach my B4x app "from the outside"). To be honest: Don't do it. Opening ports to your home will cause security issues. If you really need a server app, buy a cheap hosted server and run your app there (or via php).

If you just need to exchange massages, FCM is a good way to do that between Android devices. To store the device's token (otherwise it will get tricky), you need a server again (so it all leads to have an own server).

What are you trying to achieve? Maybe there are better ways.
 
Upvote 0

Tim_Pennard

Member
Licensed User
Thanks to you both, that’s helpful.

I’ll look at a hosted server. I’m sure this is the way to go in the long term but wondered if I could do some initial testing without this. If I use a dedicated device as a server are there still significant security risks to a home network if I open a port?

I think the port forwarding that I tried to set up may not be working. When I read the router guide I think I need to separately change the router firewall to allow it. Are there any good ways of checking if port forwarding is working? Also, am I correct that an Android phone doesn’t have a firewall itself? So there is no need to open the port on the device (just the router)?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Running a httpserver over internet is most probably blocked by your internetprovider.
It isn´t a good idea to use a Android Device for this.
- Get a VPS and run a b4j Server there.
- or use a cheap hosting an use php as a bridge.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Is it working through your local network? Have you tried a local computer with xampp instead an android device?
You can check if you've opened the port with some utils like:
https://www.yougetsignal.com/tools/open-ports/
Security risk... if you're just testing and don't have sensible data... anyway, maybe a good idea not open the standard port.
i.e. open your 81080 port in the router, and redirect to your 80 port in the device.
External port 81080 -> internal port <your device ip> port 80
 
Upvote 0

Tim_Pennard

Member
Licensed User
Running a httpserver over internet is most probably blocked by your internetprovider.
It isn´t a good idea to use a Android Device for this.
- Get a VPS and run a b4j Server there.
- or use a cheap hosting an use php as a bridge.
Thanks. To confirm, you mean that I can use the b4j version of the Jetty project and package up the b4j so it will run without needing any other software, then run that on a VPS? Sounds good.
 
Upvote 0

Tim_Pennard

Member
Licensed User
Is it working through your local network? Have you tried a local computer with xampp instead an android device?
You can check if you've opened the port with some utils like:
https://www.yougetsignal.com/tools/open-ports/
Security risk... if you're just testing and don't have sensible data... anyway, maybe a good idea not open the standard port.
i.e. open your 81080 port in the router, and redirect to your 80 port in the device.
External port 81080 -> internal port <your device ip> port 80
Thanks. Yes it works on my network. I'll look at xampp (I wasn't aware of that).
I need to go away and do some more work but I think this is essentially solved now thanks to everyone's input.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top