• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I listen a client shutdown  RSS feed

 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a Java component prototype to hit a server by multiple
client .each client when ask the server for the service from the server
server will provide a port and client will invoke the rmi://call to the service in that port and get the service .

Each client will not know if some other client is also accessing the same service using the other port .

Thats is my component and so far so good .

Now I have a problem in this program ,If a client shut down it not been known to server so the server is not unbinding the port as a result that port which was accessing by the the client is get busy for ever

I dont want that ,I want if the client is get down server automatically know the event and in that case it will unbind the port and can be used by other new client later ..

How can I catch a event in the server side that a dedicated client is down ?
I actually want to write a Listener event that listen in rmi port .
Thanks in advance .
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you calling a service? Is this a remote object available to the client?

If you are using RMI, then why do you have to get into allocating a port per client? I also dont know what are you using this port for! (You mentioned that the client uses rmi to call the service on that port which is kindda weird and i have not really seen anything like that. RMI calls are not made to a specific port. You get an object either from an RMI registry or JNDI and directly call methods on it)
RMI handles client references and cleanup using distributed garbage collection. So, if you are truly creating an RMI application, then you must not really worry about knowing whether a client is down or alive. RMI will take care of it.

Let me know if i have not understood your problem correctly.
[ May 08, 2008: Message edited by: Nitesh Kant ]
 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I am running a RMI service in different port .I have dynamically created a porrt No and run the service for that port
and pass the client the port no so when the client want to communicate
it will call on the service to the port assigned to it .

like client 1 can call the service at port 1 but client 2 will get it in port2
using syntex : rmi//x.x.xx.x/port1/Service

Now my question after calling client 2 (when both the port are busy )say client 1 disconnected ..I want my service to let it know somehow
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monoj:Actually I am running a RMI service in different port.

You mean you have exported a remote object by specifying a port number?

Monoj:using syntex : rmi//x.x.xx.x/port1/Service

I do not get a meaning of this syntax? How does a client call/execute a service using this syntax?

What stops you from registring a remote object in an rmi registry, let the clients lookup the object and call methods on it directly?
 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok forget this ..because it is running .. So no need to discuss more on what is not my problem ...

My running system can get remote object from a server using RMI ok.. and can access the service using the object as natural .. no problem is there ..

Now when this client get shut down ..how my server know about that ?
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monoj: Ok forget this ..because it is running ..

Its running does not mean that it is correct!

Monoj: So no need to discuss more on what is not my problem ...

You really think that its not your problem? If you use RMI correctly then you do not need to worry about a client coming up or going down.
You have got into this problem because you have not approached the initial problem correctly.(as far as i understand)
You can build huge frameworks to address problems that arise because of flawed design but that is not what some one should do.

Monoj:Now when this client get shut down ..how my server know about that

Well, if i forget about what else you have told till now and answer this line, then:

  • Client may inform the server while shutting down. (Client crashing screws up this approach)
  • Server honors a keep alive time. It assumes that if a client has not sent any request for the last "n" minutes, it must have gone down. (You can program a client to send heartbeats every x seconds)


  • [ May 08, 2008: Message edited by: Nitesh Kant ]
     
    Ajay Saxena
    Ranch Hand
    Posts: 154
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The whole design appears pretty weird to me. It somehow seems to me that you are having multiple RMI services ,performing probably the same operations,listening on different ports ,each for one client. That's a very strange design and I'd be really curious about what on earth could drive such a design decision,where we need to assign a server port per client.

    Unless you make the problem statement clearly,the design seems to defeat the idea of RMI based client server programming in its entirety.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!