I have a Java service running in AWS EKS. EKS Pod container exposes one HTTP port only. The service running in the container exposes RMI and HTTP ports. I have a limitation of modifying the EKS service to expose another RMI port and I can not use EKS port-forward to expose the port locally. I have shell access of the EKS Contaier.
To connect with the RMI I thought of using NGROK and exposing the TCP port using it. After exposing the port I can see the NGROK URL and the PORT, when I try to connect using JConsole it asks me to make use of the InSecure connection or cancel the connection. After selecting the InSecure option it is giving me the below error which I can see after enabling the JConsole debugger.
java.rmi.ConnectException: Connection refused to host: 0.0.0.0; nested exception is:
java.net.ConnectException: Connection refused
at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:626)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:217)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:204)
at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:134)
at java.management.rmi/javax.management.remote.rmi.RMIServerImpl_Stub.newClient(RMIServerImpl_Stub.java:83)
at java.management.rmi/javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2105)
at java.management.rmi/javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:321)
at jdk.jconsole/sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:355)
at jdk.jconsole/sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:313)
at jdk.jconsole/sun.tools.jconsole.VMPanel$2.run(VMPanel.java:296)
Caused by: java.net.ConnectException: Connection refused
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:579)
at java.base/sun.nio.ch.Net.connect(Net.java:568)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:576)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:666)
at java.base/java.net.Socket.connect(Socket.java:600)
at java.base/java.net.Socket.<init>(Socket.java:509)
at java.base/java.net.Socket.<init>(Socket.java:289)
at java.rmi/sun.rmi.transport.tcp.TCPDirectSocketFactory.createSocket(TCPDirectSocketFactory.java:40)
at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:620)
Command used to run the Java process:
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=0.0.0.0 -Dcom.sun.management.jmxremote.rmi.port=9010
And I am using JDK19
Could anyone suggest what could be the reason for this error or suggest a different approach to expose the port? The problem I am facing is in the environment where I don't have complete access of EKS.