views:

86

answers:

4

Hi,

May I know what port is used by Java RMI connection?

If I want to connect a Java client application to a Java server application using RMI connection, what port I need to open at the server machine so that the client application can connect to it?

I want to set up a firewall in the server machine but I don't know which port I should open.

Thanks.

+3  A: 

By default, RMI uses port 1099

bunting
But I heard from somewhere that some Java application connections are set to use a random port. Do you have any idea what kind of Java connection is that? Does it related to Java RMI? Thanks.
kwc
Yes and no, see http://stackoverflow.com/questions/1706685/java-rmi-client-side-random-ports for more detail on this.
bunting
+3  A: 

You typically set the port at the server using the rmiregistry command. You can set the port on the command line, or it will default to 1099

El Guapo
Can you show me how to use the rmiregistry command?
kwc
jajaj +1 nomás por el nick y la foto :)
OscarRyz
it's probably best to send you the link to the sun page with it:http://java.sun.com/docs/books/tutorial/rmi/running.htmlif it's a linux box just make sure you have the $JAVA_HOME/bin in your path and you'll be able to run the command
El Guapo
+2  A: 

RMI generally won't work over a firewall, since it uses unpredictable ports (it starts off on 1099, and then runs off with a random port after that).

In these situations, you generally need to resort to tunnelling RMI over HTTP, which is described well here.

skaffman
@skaffman: Thank you very much! Have you read the answer from El Guapo at above? Do you think that is a workable alternative solution? Can I set the port at the server to a fixed port using the rmiregistry command?
kwc
@kwc: You can set the RMI registry to a fixed port, yes, but I don't believe you can control individual client-server connections.
skaffman
+2  A: 

Geez, can't believe google is down again. anyway, seems to work from my box, so here ya go:

Java RMI FAQ (firewall)

james