My server's code looks like:
Registry r = java.rmi.registry.LocateRegistry.createRegistry(1399);
r.rebind("Chat", new IRC());
and my client's code is
IRCInterface remoteObject = (IRCInterface) Naming.lookup("rmi://localhost:1399/Chat");
String history = remoteObject.read();
on the localhost it works correctly, but I can't connect two remote computers (hosts).
I've turned off all firewalls.
What's wrong?
The console outputs:
Error: java.rmi.ConnectException: Connection refused to host: 150.254.79.20; nested exception is:
java.net.ConnectException: Connection timed out: connect
Naming.lookup("rmi://localhost:1399/Chat");
localhost in above lookup should be replaced with remotehost IP (or) machine name. Otherwise lookup happens on only local machine.
Related
Launch error: Failed to connect to remote VM. Connection timed out
Project -SDK
Connection type - Standard (Socket Attach)
Host: IP address of the SAP server
Port: 8080
There is nowhere like enough information in your question to identify the actual cause of your problem (or the fix), but problems like this typically occur because:
you are using the wrong hostname or IP address when connecting to the server
the server is off
a firewall is blocking your access to the server
there is something wrong with the network.
Hope this will give you some ideas about what to look for.
I have the a docker container (Name CON1) running in the host A, this container is a java RMI server listening on port 1099. I also have another the container (Name CON2) running a java RMI client in the host B. When I telnet CON1 from CON2 using the RMI port 1099 it works fine:
$ telnet 172.30.34.74 1099
Trying 172.30.34.74...
Connected to 172.30.34.74.
Escape character is '^]'.
But when I try to connect through the java RMI client the connection is refused and the error message shows a different IP address for CON1.
java.rmi.ConnectException: Connection refused to host: 172.18.0.2; nested exception is:
java.net.ConnectException: Connection refused (Connection refused)
Although I use 172.30.34.74 to make the lookop in the RMI client code, the error message shows other IP address (172.18.0.2). When I run the RMI server and the RMI client outside a docker container it works good.
What can I check to solve this situation?
I implemented a solution:
Add to the java command line to start the RMI server the argument -Djava.rmi.server.hostname=HOST_IP. Where host HOST_IP is the host IP.
Set the container's network_mode to host. This way, the container would take same IP as host.
If I do this:
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/imageusers?autoReconnect=true&useSSL=false&relaxAutoCommit=true", "username", "password");
then it works perfectly fine but if I do this:
Connection myConn = DriverManager.getConnection("jdbc:mysql://IP:3306/imageusers?autoReconnect=true&useSSL=false&relaxAutoCommit=true", "username", "password");
Then it gives me a long list of errors:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
I got my IP address from this website: http://whatismyipaddress.com/
and double checked it on another finder and it was the same so I don't think I'm putting in the IP address wrong. I also have made an exception for the port 3306 in windows firewall and have checked to see if MySQL was running in the services application in windows and it was. I had the MySQL program thing open and running as well. I don't know what else to do.
What you are giving here is public IP. It won't convert it to a private ip address. Try pinging to the public IP from the machine you are connecting to the DB server. It also won't work. I suggest you using a private ip address.
I have an RMI server and RMI client programs, when I execute RMI server on unix machine, and RMI client on Windows machine, I am getting
java.rmi.ConnectException: Connection
refused to host: ; nested exception is: java.net.ConnectException:
Connection refused: connect at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619) at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at the client side. I am able to execute on server and client on windows system but the server on linux is not working.
I searched using google, but I am unable to find the reason and fix.
I would appreciate your help.
Thank you in advance!
Referring the url
java.rmi.ConnectException: Connection refused to host: 127.0.1.1;
I added a line to /etc/hosts file and it works, but I am accessing the host using the IP address in my client program.
I did not understand why do we need to add a line to the /etc/hosts file.
Any comments. Thank You!.
I should be able to successfully send and receive file to/from FTP server.
But then, no changes occurred in the code and I started getting this :
Error: java.net.ConnectException: Connection timed out: connect
What I am doing is:
FTPClient ftp = new FTPClient();
ftp.connect( IPADDRESS of FTP server);
connect() is giving this execption. I am not understanding the cause for it.
The error message is telling you that the OS's attempt to connect to the server timed out. This typically means that:
the remote server has dropped off the network, or
something (e.g. a firewall) is "black holing" packets sent to the server on the FTP port.
Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the connection was refused remotely (e.g., no process is listening on the remote address/port).
Source: JavaDoc.