I was trying to launch a application on Openshift which listens to a port via ServerSocket.
ServerSocket = new ServerSocket(8080);
But it failed with the following error message:
java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at java.net.ServerSocket.<init>(ServerSocket.java:128)...
I've tried to change the port from 8080 to 8000, and then to 15000. But none of them worked.
I did search intensively on the Internet. However, I still cannot find a solution. Does anyone have a clue?
2015-12-29 edited
Proposed Reason:
Openshift allows gears to bind to port 8080. But Tomcat has already
bound 8080. So, my application is disallowed binding to the same port.
Proposed Solution:
Use DIY Cart instead. But it seems that Openshift only allows
external client to connect with http://, https://, ws:// and wss://
protocol (OpenShift Developer Guide). Applications should be modified
to handle these protocols.
Ungarida confirmed the solution and provided documentation.
I think is the only solution, take a look to this documentation.
I think using DIY cart may be a solution.
Openshift allows gears to bind to port 8080. I suspect that Tomcat has already bound 8080. So, my application is disallowed bind to the same port.
I've tried DIY cart and I got no exception. But it seems that Openshift only allows external client to connect with http://, https://, ws:// and wss:// protocol (OpenShift Developer Guide). I have to modify my application to handle these protocols.
Does anyone know other solution?
Related
I have deployed my java web application using apache tomcact in my system through Eclipse. I can access the same page with
https://localhost:8080/Home.jsp
as well
https://mysystemip:8080/Home.jsp
But the same page is not able to connect
https://mysystemip:8080/Home.jsp over the network through other systems. Previously it was working and now not. What issue causing this ?
Your Tomcat server is only bound to your local network interface. You need to bind it to all interfaces for it to be available.
There is already a solution (Can't access Tomcat using IP address):
Add address="0.0.0.0" to Connector string
I'm trying to set up three services to run on the same port (port 80). Two of the services are hosted on IIS thus enabling bindings to use the same port. One of the three services is however hosted on a Tomcat server as it is a Java Servlet. How can i set this up so that all can be accessed through port 80?
I've tried using URL Rewrite in the IIS to forward the request to port 8080 where the Tomcat service is active but it doesn't work with other services being active on port 80.
Any other ideas?
EDIT
I have no support for URL Rewrite not working for this purpose other than my own attempts. If anyone have used it and knows it should work, please shout out as it would be an optimal solution with minimal complexity to the system!
I am developing a web application in Java by using RESTful web services and Tomcat. So far I was using the localhost in the URI: http://localhost:8080/3.ServerAPI/rest/Variable. But what if I want to use the real IP?
I have tried that on a local network by replacing the localhost with the LAN IP and it works fine: http://192.168.1.2:8080/3.ServerAPI/rest/Variable
The application at this address received the Variable.
If I want to send this through the internet as long as I know I have to use the WAN IP: http://188.39.25.247:8080/3.ServerAPI/rest/Variable
My question is, if I use the last URI with the WAN IP do I need also to port forward to the LAN IP by configuring the router or it is going to work like when I used the LAN IP ??
Thanks in advance
It depends on your network setup really.
You may have to enable port forwarding on your router to direct the request to the machine that your server is on, also make sure that the router allows connections to port 8080.
I had to do this recently when working with callbacks on external APIs. Seem to remember that I had to enable port forwarding on my router to get it to work. Wasn't too difficult though, just check router instructions on how to do it - like I say, depends on network setup though.
Hope this helps.
I've seen something similar to this and the problem was due to the port being used by another application.
When I run ActiveMQ by executing the batch file in its bin/ directory, I am able to go to its admin/management console by opening a web browser and going to http://localhost:8161/admin/.
This has me curious.
This is my local sandbox and I do not have any web server (httpd or otherweise) installed. So how is it that ActiveMQ is able to "register" a port on my machine, and listen to it exclusively?
If I try to go to http://localhost:8162/admin/ (notice the different port #), I get an unable to connect error.
Somewhere, somehow, AMQ is saying "map this URI (localhost:8161) to some root directory on this machine". As a programmer, I'm interested in how something like this works.
A Java process is able to use any port (>= 1024 on linux) as a web server or for any other purpose. You don't need a separate web server to do this
I suggest you read up on sockets: here. All a web server is, is a socket listener that handles the HTTP protocol. HTTP protocol is here.
Web servers often handle a lot of other things, but that is the basics. If you want a small program that also runs a web server I suggest not re-inventing the wheel. Try incorporating jetty into your server.
ActiveMQ starts an embedded Jetty server, which listens for HTTP connections on that port. You don't need any other server running. It's all done from Java. If you dig down deep enough, you'll find some variety of ServerSocket at the bottom of it all. You can learn all about sockets and listening on ports in the Java Tutorial.
At its simplest level, ActiveMQ is creating a ServerSocket instance within itself and listening for connections using this server socket. A socket is always bound to a port.
One: this port is greater than (or equal to) 1024, so it means a "non root" user can listen on it.
Second: you can bind to ports from dedicated addresses only. This means ActiveMQ may have only opened that port on 127.0.0.1 (localhost). Try and see if you can open that URL from your external interface's IP address: chances are you cannot.
If you are under a Unix system, you can check what program listens on which port by using netstat -ltpn.
The basic system call for binding to a port is listen(2).
I need some help from someone who understands JBoss Hostname Binding. I think the solution is easy, although it's complicated to explain.
I am deploying an application using JBoss (v4.2) and am having troubles configuring the application.
This application has two parts, a web site on port 8080 and web services on port 8080 using SOAP APIs.
My server sits behind a firewall, and has an alias, let's say it's called orange.mycompany.com
My problem is that I cannot get the console to connect to the web services. The website works, but I see an connection refused error connecting to the web services.
[xfire.transport.http.HttpChannel]
java.net.ConnectException: Connection
refused
There are 2 things I can control, the bind IP on Tomcat, and the URL of the web services.
If I start JBoss, and bind to the local IP address:
./run.sh -b 10.1.2.3
And I set the URL of the web services to be that same IP
url=http://10.1.2.3:8080/services
I can see the website on port 8080 from outside the firewall, but the console cannot connect to webservices.
From the server, orange, itself I cannot see the website by calling http://localhost:8080/ or http://10.1.2.3:8080 or orange.mycompany.com:8080
However, if I start JBoss and bind to 127.0.0.1:
./run.sh -b 127.0.0.1
And I set the URL of the web services to localhost
url=http://localhost:8080/services
Now I can't see the website at all from outside the firewall.
But from the server itself, I can see the website browsing http://localhost:8080 and the I can successfully connect to the web services. That's great, but I need the website to be accessible from outside.
Can anyone suggest any combination of settings that will let me browse the website and also let the console call webservices on localhost?
Never mind.
Start JBoss binding to all IP's works.
./run.sh -b 0.0.0.0
Aren't your running JIRA standalone, right?
I always run tomcat and jboss behind a apache with mod_jk. This still hide ports, what sounds great for newbies users.
Your server is behind a NAT?
Sometimes I use ProxyPass or RewriteRules (mod_rewrite) to provide external access, thru reverse proxy.