Home Help Center

Idle functions possible?

cokecoke Member
I am a bit puzzled by how Ice behaves when it is idle. For this particular problem I have also read a bit on ACM, but I am not sure if that is what I want it to do.

I have a server in Ice, and several clients connecting to it. So far I understand that the connections are non-persistent, i.e. client connects, does a request, and then it disconnects. Correct me if I am wrong. The clients will be sending a heartbeat to the server every few seconds to tell the server it is still there. The server will then accept the heartbeat and keep track of the last heartbeat timestamp.

Now, what I'd like to do, is for the server to periodically, say, in its idle time, check in its table of client connections if a client has not been heartbeating for a certain amount of seconds. When that threshold has been passed, the client is regarded as disconnected.

I know there is a ConnectionIdleTime property in Ice, but I'm not sure what the impact is. 'Cause I want the server to take some action when a client disconnects, i.e. remove the client ID from the list of connected clients, and remove the pending messages for that client from the Messages database. I want to be able to do that kind of thing. Can anybody give me directions as to how to do this?

Thanks in advance.

Comments

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

    Connections are managed transparently by Ice. A connection is established automatically the first time a client uses a proxy. If automatic connection management (ACM) is enabled, that connection is gracefully shutdown after it has been idle for a specified time, but it is not currently possible for an application to be notified when a connection is shutdown.

    It sounds like what you want is session management, however the lifetime of a session doesn't necessarily need to be bound to the lifetime of a connection. In other words, you should define session expiration and heartbeat intervals based on application requirements, not on the behavior of Ice's internal connection management. If you do enable ACM, it would obviously be beneficial to set the connection idle timeout to a value larger than the heartbeat interval, so that connections are not continually shutdown and reestablished.

    Session management is a subject that is raised repeatedly by Ice users, and we are planning to make it easier to incorporate into applications. Meanwhile, you should have a look at the source code for the Glacier2 router, which implements session management.

    Take care,
    - Mark
Sign In or Register to comment.