You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Rohan Desai <de...@gmail.com> on 2012/04/11 03:41:02 UTC

DISCONNECTED and SESSION_EXPIRED events

Im new to zk and had some questions about connection loss events. From what
I understand when a ZK handle loses connection to the ZK cluster, the ZK
client's watch handler receives a DISCONNECTED event. If the connection is
lost for longer than the session timeout, the ZK client's watch handler
receives a SESSION_EXPIRED event and the handle is closed. If this is
correct, does the ZK client's watch handler receive the DISCONNECTED event
right after the client loses its connection to the cluster? When does the
client get the SESSION_EXPIRED event? Does it get it after the client
detects the session would have timed out or only after the client is able
to re-establish a connection to the ZK cluster?

Re: DISCONNECTED and SESSION_EXPIRED events

Posted by Mark Gius <mg...@gmail.com>.
You should get a CONNECTING state when you lose connectivity to zookeeper.
 I have never seen a DISCONNECTED state from the C bindings anyway.

Mark

On Wed, Apr 11, 2012 at 11:35 AM, Rohan Desai <de...@gmail.com>wrote:

> Thanks, that answers the second part of my question. However im still
> unclear as to when the DISCONNECTED event will be received. Im currently
> assuming that Ill get it immediately after the connection is lost.
>
> On Tue, Apr 10, 2012 at 10:34 PM, Patrick Hunt <ph...@apache.org> wrote:
>
> > On Tue, Apr 10, 2012 at 6:41 PM, Rohan Desai <de...@gmail.com>
> > wrote:
> > > Im new to zk and had some questions about connection loss events. From
> > what
> > > I understand when a ZK handle loses connection to the ZK cluster, the
> ZK
> > > client's watch handler receives a DISCONNECTED event. If the connection
> > is
> > > lost for longer than the session timeout, the ZK client's watch handler
> > > receives a SESSION_EXPIRED event and the handle is closed. If this is
> > > correct, does the ZK client's watch handler receive the DISCONNECTED
> > event
> > > right after the client loses its connection to the cluster? When does
> the
> > > client get the SESSION_EXPIRED event? Does it get it after the client
> > > detects the session would have timed out or only after the client is
> able
> > > to re-establish a connection to the ZK cluster?
> >
> > Some good details in the faq on this:
> > https://cwiki.apache.org/confluence/display/ZOOKEEPER/FAQ
> >
> > It's not exactly as you describe - for example you can't know the
> > session is expired until you reconnect to the server.
> >
> > Also see this section in the programmer guide:
> >
> >
> http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#ch_zkSessions
> >
> > Patrick
> >
>

Re: DISCONNECTED and SESSION_EXPIRED events

Posted by Rohan Desai <de...@gmail.com>.
Thanks, that answers the second part of my question. However im still
unclear as to when the DISCONNECTED event will be received. Im currently
assuming that Ill get it immediately after the connection is lost.

On Tue, Apr 10, 2012 at 10:34 PM, Patrick Hunt <ph...@apache.org> wrote:

> On Tue, Apr 10, 2012 at 6:41 PM, Rohan Desai <de...@gmail.com>
> wrote:
> > Im new to zk and had some questions about connection loss events. From
> what
> > I understand when a ZK handle loses connection to the ZK cluster, the ZK
> > client's watch handler receives a DISCONNECTED event. If the connection
> is
> > lost for longer than the session timeout, the ZK client's watch handler
> > receives a SESSION_EXPIRED event and the handle is closed. If this is
> > correct, does the ZK client's watch handler receive the DISCONNECTED
> event
> > right after the client loses its connection to the cluster? When does the
> > client get the SESSION_EXPIRED event? Does it get it after the client
> > detects the session would have timed out or only after the client is able
> > to re-establish a connection to the ZK cluster?
>
> Some good details in the faq on this:
> https://cwiki.apache.org/confluence/display/ZOOKEEPER/FAQ
>
> It's not exactly as you describe - for example you can't know the
> session is expired until you reconnect to the server.
>
> Also see this section in the programmer guide:
>
> http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#ch_zkSessions
>
> Patrick
>

Re: DISCONNECTED and SESSION_EXPIRED events

Posted by Patrick Hunt <ph...@apache.org>.
On Tue, Apr 10, 2012 at 6:41 PM, Rohan Desai <de...@gmail.com> wrote:
> Im new to zk and had some questions about connection loss events. From what
> I understand when a ZK handle loses connection to the ZK cluster, the ZK
> client's watch handler receives a DISCONNECTED event. If the connection is
> lost for longer than the session timeout, the ZK client's watch handler
> receives a SESSION_EXPIRED event and the handle is closed. If this is
> correct, does the ZK client's watch handler receive the DISCONNECTED event
> right after the client loses its connection to the cluster? When does the
> client get the SESSION_EXPIRED event? Does it get it after the client
> detects the session would have timed out or only after the client is able
> to re-establish a connection to the ZK cluster?

Some good details in the faq on this:
https://cwiki.apache.org/confluence/display/ZOOKEEPER/FAQ

It's not exactly as you describe - for example you can't know the
session is expired until you reconnect to the server.

Also see this section in the programmer guide:
http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#ch_zkSessions

Patrick