Android Question Internet access port 80?

Darsiar

Member
I have a rooted device, and other programs run on port 80.
I am trying to set up a server from example:

and I get error on line 3

java.net.BindException: bind failed: EACCES (Permission denied)

B4X:
Sub Service_Create
    server.Initialize("Server")
    server.Start(80)
    templates.Initialize
    Dim n As Notification
    n.Initialize
    n.Icon = "icon"
    n.SetInfo("Http Server is running", "", Main)
    Service.StartForeground(1, n)
End Sub
What permissions do you need to give a program to have access to port 80?
 

Darsiar

Member
I understand this, and therefore I ask such a specialist as you. After all, you have created an absolutely ingenious product that can really be compared with the creation of Microsoft "Visual Basic"!
I am sure you can give specific advice, because,
for example well-known programs for Android:
Palapa web server
Kws server
and others, written in Visual Basic, not only easily work in root with port 80, but also offer forwarding of external and local ports, if necessary.

Therefore, your instruction can easily do this.
Please tell me, this is really very necessary.
We want to make our own version of such a server for Android.

Thanks in advance.
With great respect.
Alexander.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Palapa web server
Kws server
Palapa use porta 8899
Kws server use 8080
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
 
Upvote 0

Darsiar

Member
Maybe so?
B4X:
sur.SuCommand ("iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080")
server.Start (8080)

Android says root is allowed, but the server is not redirected!

Please advise.

Thanks in advance!
With respect.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
You wrote:
I have a rooted device, and other programs run on port 80.

And you want to start:
B4X:
    server.Initialize("Server")
    server.Start(80)

You cannot start a second server which use the same port 80 So I think that this is the reason for the "Permission denied" error because there is no free port 80.

I'm not an expert in using IPtables under Android. However, there is an old post https://stackoverflow.com/questions/4577268/iptables-in-android#5409563 which indicate that there are restricts to use IPtables under Android. There is also asked 11 days ago without currently unanswered https://stackoverflow.com/questions/67592271/how-to-get-port-forwarding-in-android-from-8080-to-80.

So I think that your best bet is to dived your solution in several steps to see what works and what not work by start and test a web server on port 80. Next step add the rerouting from port 8080 to 80, then add NAT and see how far everything works as expected.
 
Upvote 0

Darsiar

Member
You wrote:


And you want to start:
B4X:
    server.Initialize("Server")
    server.Start(80)

You cannot start a second server which use the same port 80 So I think that this is the reason for the "Permission denied" error because there is no free port 80.
B4X:
sur.SuCommand ("iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080")
server.Start (8080)

I'm not an expert in using IPtables under Android. However, there is an old post https://stackoverflow.com/questions/4577268/iptables-in-android#5409563 which indicate that there are restricts to use IPtables under Android. There is also asked 11 days ago without currently unanswered https://stackoverflow.com/questions/67592271/how-to-get-port-forwarding-in-android-from-8080-to-80.

So I think that your best bet is to dived your solution in several steps to see what works and what not work by start and test a web server on port 80. Next step add the rerouting from port 8080 to 80, then add NAT and see how far everything works as expected.

Thank you very much for your reply!
However, we have found a reliable solution that we can recommend to everyone:
1) Buy a SIM card for data transfer (web things) from a mobile operator, which has a static IP address. This is usually not expensive at all, and assumes unlimited traffic on 4G (3G on failure). In Belarus, this service costs $ 4 per month.
2) Root the device with the Lutsk patcher program (or similar)
3) Install directly in the Basic program the forwarding codes written above to port 8080

B4X:
sur.SuCommand ("iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080")
server.Start (8080)
This solution works just fine on all Android.
We have already received the great HTTP server from the phone, following the example of the dear Mr. Erel!
Good connection and high speed.
Thanks Erel!
Now we will improve the server and the CMS program for it ...
Good luck to all
 
Upvote 0
Top