I have a problem with my RMI application. After about 20 hours (+/- several hours), clients can no longer connect. In the first 20 hours of the server, although I can make as many connections as I want. I suspected that the problem with the remote RMI object was the garbacge assembly, since there are no links pointing to it, but I can eliminate this for two reasons:
- I got the JVM to start the server to create the GC using jconsole, and clients can connect
- I keep the link to my server in the main method, which I do not exit, and the RMI registry and stub are members of my server class.
My server creates an RMI registry on port 1099 and is exported as UnicastRemoteObject to port 5099. When clients can no longer connect after 20 hours, I get a java.rmi.ConnectException exception. To be clear, the server-side Java process is still running, and the registry (running in this process) is still responding and returning the remote object. An exception occurs when I call a remote method on the client side.
If I use "netstat -tulpn" on my server, I see that the java process first listens on port 5099, but as soon as the 20-minute errors on the server stop listening on this port. I think that I can also eliminate the problems with the firewall, since I turned off the server firewall for testing. Below is a simplified version of my code. Any ideas on what was going on there and how to make the server live indefinitely would be greatly appreciated. Hooray!
import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; public class MyRMIServer implements MyRMIInterface { private MyRMIInterface stub; private Registry registry; public static void main(String[] args) { MyRMIServer server = new MyRMIServer(); server.startRmiServices();
source share