2

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.

Community
  • 1
  • 1
Clark
  • 23
  • 6
  • From the error message you don't have a permission to bind socket. Try with root user also check the firewall. – Shriram Dec 26 '15 at 13:23
  • I don't think I can get root access on OpenShift, as SFERICH from [this post](http://stackoverflow.com/questions/17797239/what-can-i-do-as-openshift-user) suggested. – Clark Dec 27 '15 at 01:51

2 Answers2

0

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?

Community
  • 1
  • 1
Clark
  • 23
  • 6
0

I think is the only solution, take a look to this documentation.

Davide Ungari
  • 1,920
  • 1
  • 13
  • 24