sockets – Openshift java.net.SocketException: Permission denied

sockets – Openshift java.net.SocketException: Permission denied

I was trying to find out solution. I have got some solutions. All are suggesting to add -Djava.net.preferIPv4Stack=true to the VM options.

Atlassian Documentation also got the root cause and solution given below:

Cause

  1. This is one of the known issues with Java 7, as per this post.
  2. This can also be caused by any anti-virus or firewall software
    installed on the server.

Resolution

  1. Use the -Djava.net.preferIPv4Stack=true JVM system property to help
    enable support for IPv4 on Java 7.
  2. Check that anti-virus and firewall software on the server is not
    blocking Stashs ability to connect to the mail server.

This solution is for Java 7, but you are using Java 8. So I lookup your stacktrace. There is a line

 at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125)

Which is telling that you are using netty.

But netty has some requirement on version basis. There is also some limitations.

JDK 5 (Netty 3.x) or 6 (Netty 4.x) is enough. Some components such as
HTTP/2 might have more requirements

Requirements for Netty 4.x(link)

Java does not currently support ALPN or NPN (there is a tracking issue so go upvote it!). For lack of support in the JDK we need to
use the Jetty-ALPN (or Jetty-NPN if on Java < 8) bootclasspath
extension for OpenJDK.
To do this, add a Xbootclasspath JVM option
referencing the path to the Jetty alpn-boot jar.

java -Xbootclasspath/p:/path/to/jetty/alpn/extension.jar ...

Note that you must use the release of the Jetty-ALPN jar specific
to the version of Java you are using.

JDK Ciphers

Java 7 does not support the cipher suites recommended by the HTTP2 RFC. To address this we suggest servers use Java 8 where
possible or use an alternative JCE implementation such as Bouncy
Castle
. If this is not practical it is possible to use other
ciphers but you need to ensure that the services you intend to call
also support these ciphers forbidden by the HTTP/2 RFC and have
evaluated the security risks of doing so.

Enabling ALPN or NPN

The SslContextBuilder has a setter for an ApplicationProtocolConfig which is used to configure ALPN or NPN.
See the HTTP/2 examples for ALPN and SPDY examples for NPN
usage.

For details description, you can go through this link.

Suggestions:

So check your netty version and take decision according above issues. Or use JDK 7 if possible.

The linked blog post says that you can connect to websockets on OpenShift using ports 8000 and 8443. However, the server itself needs to be bound only to port 8080 and then you can connect externally to the ws ports above. This diagram that you have already found explains the configuration.

WildFly is using 8080 already, so you may want to use the DIY cartridge to deploy your app (dont forget to disable the default ruby server in the start action hook that is running on 8080) or be inspired here.

sockets – Openshift java.net.SocketException: Permission denied

Leave a Reply

Your email address will not be published.