• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Clients' connections

 
Flavio Nobili
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all,
Does anyone know how can I control the connection of clients on the server side? I've tried to use RMISocketFactory, but it didn't work. I would like to know if one client is still connected or not.

Thanks,
Fl�vio.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fl�vio,
If you create a new connection for each client (use a connection Factory), then you will be able to have the connection class implement the Unreferenced interface. When that connection is dropped (deliberate disconnection or through network fault / client crash) your unreferenced method will be called.
Regards, Andrew
 
Flavio Nobili
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Andrew,
I've tried unsing the UnicastRemoteObject interface, but it's not really worked, and I don't understand why.
I have a factory class, registered in the RMI runtime, which gives a new instance of the Database class for each client that calls getDatabase method. The Database class is a remote object that implements the UnicastRemoteObject interface. The unreferenced method just displays something. So, when a client is closed something should be displayed on the screen, but it doesn't happen. Do you know what is wrong?


Regards,
Fl�vio
[ February 04, 2004: Message edited by: Fl�vio Fran�a ]
 
Stephen Galbraith
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried waiting 10 minutes? I think the default timeout for this is something around that time, so if you haven't changed it you'll have to wait!
Steve
 
Flavio Nobili
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stephen,
I've tried wainting 10 minutes, and it works this way. Thanks for helping. Do you know how I change this timeout?

Regards,
Flavio
 
Stephen Galbraith
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, sorry
but I think you have to set the timeout for the underlying socket
(but again don't ask me how - I've just got my RMI up and running, need to refactor majorly though At the minute I'm back to re-working the wait and notify on my record locking to be @ the record level - is there no end???)
Steve
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Flavio,
I've tried wainting 10 minutes, and it works this way. Thanks for helping. Do you know how I change this timeout?

You can try:
System.setProperty("java.rmi.dgc.leaseValue", "10000");
(Or set it at the command line)
This will set the timeout to 10 seconds - very useful when testing your code.
However I would not change this value in your final submission (or at least, leave it at the default value, and allow the user to modify it if they wish). There are messages sent over the network at the halfway point of the lease expiration (so at 5 seconds in my setup), and if you have a lot of clients connected then this could generate a lot of unnecessary network traffic. Plus you may inadvertantly loose connections over a WAN because of network latency.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic