I'm trying to make my RMI service work across a Firewall. I followed instructions in this answer to run both RMI Registry and my RMI service on port 1099, yet, I'm seeing different port numbers being opened on RMI client and server when I do netstat
.
[user@machine] ~ $ netstat -ant | grep 1099
tcp6 0 0 :::1099 :::* LISTEN
tcp6 0 0 10.1.1.1:1099 10.1.1.2:33400 ESTABLISHED
tcp6 0 0 10.1.1.1:1099 10.1.1.1:33378 ESTABLISHED
tcp6 0 0 10.1.1.1:33408 10.1.1.1:1099 ESTABLISHED
tcp6 0 0 10.1.1.1:1099 10.1.1.1:33408 ESTABLISHED
tcp6 0 0 10.1.1.1:46866 10.1.1.2:1099 ESTABLISHED
tcp6 0 0 10.1.1.1:1099 10.1.1.2:33404 ESTABLISHED
tcp6 0 0 10.1.1.1:33378 10.1.1.1:1099 ESTABLISHED
tcp6 0 0 10.1.1.1:46862 10.1.1.2:1099 ESTABLISHED
tcp6 0 0 10.1.1.1:46864 10.1.1.2:1099 ESTABLISHED
tcp6 0 0 10.1.1.1:1099 10.1.1.2:33402 ESTABLISHED
tcp6 0 0 10.1.1.1:46860 10.1.1.2:1099 ESTABLISHED
10.1.1.1 and 10.1.1.2 are both RMI servers and clients talking to each other.
This is my code snippet:
IRemoteService stub = (IRemoteService) UnicastRemoteObject.exportObject(service, 1099);
registry = LocateRegistry.createRegistry(1099);
registry.rebind(IRemoteService.serviceName, stub);
Is this expected? Why am I seeing port #'s like 33400, 33378 etc? Or is my understanding of how source and destination ports work wrong? I was hoping to see all connections (registry lookup and remote service calls) going to port 1099 only.
Note: I did not run the above in a Firewall environment yet, just trying locally in my lab before I try in a Firewall situation.