Don't forget to compile your remote classes with rmic!.In your client-side code do Naming.lookup("//the-remote-ip:1099/remoteObjectName"). ![]() If you do not do this, then Java will use an anonymous port (which will probably get blocked remotely). IMPORTANT:Any objects which intend to receive any response, rather than extend UnicastRemoteObject, use the following code: UnicastRemoteObject.exportObject(yourObject, 1100) This will allow your object to listen for remote calls on port 1100 (which we have port forwarded).Please note that you cannot use rebind on an external IP. ![]() However, because we are using port forwarding, we are telling our router to direct any packets to 1099 to our local IP address. rebind("//your-local-ip:1099/remoteObjectName") This will bind the object to your local machine. Note that this is not required for clients to receive a response. Run rmiregistry in your codebase on any servers.This latter is arbitrary though and can be replaced by a different port if you prefer. As for port 1100, we're going to use this for communicating with remote objects. Why? 1099 is the defacto-standard port for Java RMI. If you would like to start from scratch, see Oracle's official documentation. ![]() ![]() Please note that this post assumes a basic understanding of Java RMI. Many of us are familiar with Java RMI but to get it working over the internet is a bit more involved, at least in my own experience of doing so.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |