Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to access without port number(:8080) #612

Closed
kishansinghpanwar opened this issue Aug 26, 2021 · 4 comments
Closed

Not able to access without port number(:8080) #612

kishansinghpanwar opened this issue Aug 26, 2021 · 4 comments

Comments

@kishansinghpanwar
Copy link

kishansinghpanwar commented Aug 26, 2021

Hi,
I have searched everywhere but can't figure out how to do this.
Basically, I want to remove the :8080 from my URLS so my portal will be ready for deployment. When I type in http://191.161.43.159/ I want to access the portal, rather than typing in http://191.161.43.159:8080

How does one do this?

Any advice would be great!

Thanks in advance,
Kishan Singh

@kishansinghpanwar kishansinghpanwar changed the title Not able to access without port number. Not able to access without port number(:8080) Aug 26, 2021
@ItsHarper
Copy link

To do this, pass in 80 as the parameter to the NanoHTTPD constructor, rather than 8080. Port 80 is the port that browsers default to for HTTP (not HTTPS).

@kishansinghpanwar
Copy link
Author

@NoahAndrews Thanks for the suggestion, but whenever I'm trying to provide the port number different than 8080, I'm getting errors while starting the server connection and same result I got when I tested with "80" port.

Getting error while binding InetSocketAddress to ServerSocket, here are the code:

try {
    myServerSocket.bind(hostname != null ? new InetSocketAddress(hostname, myPort) : new InetSocketAddress(myPort));
    hasBinded = true;
} catch (IOException e) {
    this.bindException = e;
    return;
}

And here are the error logs :

W/System.err: java.net.BindException: bind failed: EACCES (Permission denied)
W/System.err:     at libcore.io.IoBridge.bind(IoBridge.java:103)
W/System.err:     at java.net.PlainSocketImpl.socketBind(PlainSocketImpl.java:157)
W/System.err:     at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:427)
W/System.err:     at java.net.ServerSocket.bind(ServerSocket.java:377)
W/System.err:     at java.net.ServerSocket.bind(ServerSocket.java:331)
W/System.err:     at java.lang.Thread.run(Thread.java:764)
W/System.err: Caused by: android.system.ErrnoException: bind failed: EACCES (Permission denied)
W/System.err:     at libcore.io.Linux.bind(Native Method)
W/System.err:     at libcore.io.ForwardingOs.bind(ForwardingOs.java:60)
W/System.err:     at libcore.io.IoBridge.bind(IoBridge.java:99)
W/System.err: 	... 6 more

I have tried to find the solution for this error and found this error appears when the app don't have Internet permission(android.permission.INTERNET) or access network state permission(android.permission.ACCESS_NETWORK_STATE), but I have already defined both permissions in the AndroidManifest file.

@ItsHarper
Copy link

Oh, binding to ports below 1024 typically requires root permissions on Linux, so you'd have to root your phone for that to work on Android. If you're looking to distribute the app widely, you're going to be stuck with 8080.

I actually work for a company that sells an Android device that you access over port 8080, and I don't think we really get any complaints about having to specify the port.

@kishansinghpanwar
Copy link
Author

Thanks for your help.
Yes, I also think so this might be a reason, but I think instead of rooting my phone, I can bind the app with the framework as System App, and I think in that case the app have access of 80 port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants