Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Client server Starting Order?

 
Rob Shepherd
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a funny one.....
imagine this if you will.....
I have an RMI server object
it 1. starts a thread to broadcast it is alive
2. Registers with the Registry
3. Waits for method calls
I have an RMI client
it 1. Has a thread which detects bcast packets
2. Instanciates an RMI client and does Named.lookup(address, object)
every time it finds a bcast packet from a new machine.
The order Start a server hostA, start a server hostB, start the clientside hostC
works fine...no worries i can use the RMI clients and talk to all servers.
However....
if i start the Clientside hostC....it sits and waits for userinput (so don't touch anything), then start server hostA, i see the client pick up the bcast, instanciate a RMI client object, do a successful Naming.lookup
no problem
now if i try and call a remote method it says....Connection refused.
if i start serverA clientC serverB. the client side can use remote method on A but connection refused on B.... why might this make a difference?
remember there is a thread to create unique RMI clients, and my program just picks a client from the set to use. i have no problem running server,server,client?
does anybody know the internals of RMI and why it may have a problem?
Many thanks in anticipation
[ December 08, 2003: Message edited by: Rob Shepherd ]
 
Rob Shepherd
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suddenly it dawned on me....
it took mental flow charts and some soothing whale music but heres the solution.
in my case The registry is a global service (not started by me and runs forever),
now i havn't been shutting down my services properly (unbinding) so the registry holds a stub for an old remote object.
my broadcasting and receiving threads are too fast so my service broadcasts and then tries rebind(), but the client picks up the bcast and queries the registry before the server can rebind to it gets the old one!
a simple sleep(1000) sorts it out (for me anyway, server on a SunFire v100)
i seem to have worn a hole in the top of my head from all that scratching!!
hope people find this if they get a similar problem - it's taken ages for me to work out.
Out
Rob
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, and thanks for the lesson!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!