Home Help Center

Using callback on server after closing client

adamsajdakadamsajdak Member Adam sajdakOrganization: Univerisy of Science and Technology in CracowProject: Distributed genetic algorithms computation
Hi,
I've just started working with ICE and I have serious problem just in the beginning. I have written working client and server, and server is able to communicate with specific client using callback. My problem is what happens when I close client without informing about that server(for example operating system has crashed). I know that after some time session will timeout( I am using Glacier2), but before that when server calls any callback method program hangs while trying to connect... So is there any method to check from server side if client is still connected, just having its callback proxy object?

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Adam,

    Welcome to the forum.

    There's no reliable way for a server to determine whether a client is still connected. The best approach is to program defensively and assume that any invocation on the client might block. You should use asynchronous invocations if you want to avoid the possibility of blocking your server while it makes a callback to the client; Ice guarantees that asynchronous invocations never block, including during the connection establishment phase. I would also recommend that your server configure a timeout on its callback proxy.

    Regards,
    Mark
  • adamsajdakadamsajdak Member Adam sajdakOrganization: Univerisy of Science and Technology in CracowProject: Distributed genetic algorithms computation
    Hi,
    thanks for the help. Now I'm using asynchronous calls. But there is yet another problem, on client side I'm using separate thread to constantly refresh session to be able to avoid destroying this session on server side. And everything works great during first connection, the client is stable connected to server for several time. Problem occurs when I close client(session manager destroys session) and connect it again... Server after some time destroys session as there would not be any pining thread on client side. And after that if I close server I got exception form pining thread that server is not available(which is normal behaviour).
    This is the code used in pinging thread:
    while (work)
                {
                    try
                    {
                        router.refreshSession();
                        Thread.Sleep(1000);
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine(e);
                    
                    }
                }
    
Sign In or Register to comment.