aspose file tools*
The moose likes Distributed Java and the fly likes RMI client behind NAT. Callback implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "RMI client behind NAT. Callback implementation" Watch "RMI client behind NAT. Callback implementation" New topic
Author

RMI client behind NAT. Callback implementation

Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Here is my trick to perform RMI callbacks when client (server is not problematic) is behind a NAT.
It's based on keeping RMI client sockets opened, since client behind a NAT has not routable addresses.
The solution can be also an alternative to firewalled client environments, where only outgoing connections to popular ports are permitted.

Please read it, and post your ideas,comments,improvements,drawbacks...

Here is an example code, showing the basics:


Middle tier:
Remote interface:


Server event:


Server:


Client: Client starts a new thread for the server listener:


[ July 22, 2006: Message edited by: Oricio Ocle ]

SCJP, OCMJD, OCMJEA
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Maybe some comments?
Jared Cope
Ranch Hand

Joined: Aug 18, 2004
Posts: 243
Hi,

Originally posted by Oricio Ocle:
Maybe some comments?


Okay, I see what you are doing and I think it's a fine idea. I'm just wondering how I can adapt it to serve 70-80 clients that might connect to one server. I assume I would need to have a differnt mutex to synchonize on (and wait/notify) for each client that wanted to connect and be notified.

The scenario I need to solve is an observer pattern where there are different conditions to whether certain clients should be notified of something. Therefore a single mutex won't work for my case.

But just thinking about it, I can certainly see how I could adapt it to work. Very interesting idea. I'll definitely think more about it.

Cheers, Jared.


SCJP 1.4 91%, SCJP 1.5 88%, SCJD B&S
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284


But just thinking about it, I can certainly see how I could adapt it to work. Very interesting idea. I'll definitely think more about it.


Yes, it's easily adaptable to your case.
Think about it, I'll wait your comments..

Regards
Chris Janicki
Greenhorn

Joined: Aug 30, 2006
Posts: 21

Also consider overriding RMISocketFactory. I posted some notes here:

Augur Systems: Java RMI Tips

I also corrected an error someone pointed out in the previous thread here.
Fors Judd
Greenhorn

Joined: Mar 26, 2012
Posts: 6
What are the time limitations of this idea?
Will the Client eventually time out if the Server holds the call for 10 seconds? 100 seconds?
Is there a way to change the timeout limit?

Is the timeout dependable? Can the Client be programmed to count on a timeout after a given amount of time?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI client behind NAT. Callback implementation
 
Similar Threads
RMI UnmarshalException
why is it necessary for unLock() to check clientID?
RMI server keeps running in MAC OSX platform but not in Windows XP platform
RMI pass by value or by reference ?
Socket and InputStream