You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Julien Vey <Ju...@bull.net> on 2010/04/21 10:44:41 UTC

Client reconnection after a connection loss

Hi all,

I'm currently working with ZooKeeper in CXF D-OSGI and i'm facing a 
problem that would require your help.

When a client is connected to the ZooKeeper server, and the connection 
is lost, it throws a ConnectionLossException.
The problem is when the connection is back, the client doesn't reconnect 
itself. I can see the following trace on the server

2010-04-20 17:44:21,526 - INFO  [NIOServerCxn.Factory:> 
0.0.0.0/0.0.0.0:2181:NIOServerCnxn$Factory@251] - Accepted socket 
connection from /129.183.128.230:60471
2010-04-20 17:44:21,526 - INFO  [NIOServerCxn.Factory: 
0.0.0.0/0.0.0.0:2181:NIOServerCnxn@742] - Client attempting to renew 
session0x1281ba54e900005 at /129.183.128.230:60471
2010-04-20 17:44:21,527 - INFO  [NIOServerCxn.Factory: 
0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1424] - Invalid session 
0x1281ba54e900005 for client /129.183.128.230:60471, probably expired
2010-04-20 17:44:21,527 - INFO  [NIOServerCxn.Factory: 
0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1286] - Closed socket connection for 
client /129.183.128.230:60471 which had sessionid 0x1281ba54e900005

The client tries to reconnect with an expired session id.
Is it possible to configure zookeeper in order that it accepts this 
connection by recreating a new session, or maybe something else that 
would make the reconnection works ?

Thanks in advance for your help

Julien.




Re: Client reconnection after a connection loss

Posted by Qian Ye <ye...@gmail.com>.
so far as I know, you should keep an eye on your client handler and
reconnect to Zookeeper server when it is expired youself. It's the solution
in my application for this kind of  situation.

On Wed, Apr 21, 2010 at 4:44 PM, Julien Vey <Ju...@bull.net> wrote:

> Hi all,
>
> I'm currently working with ZooKeeper in CXF D-OSGI and i'm facing a problem
> that would require your help.
>
> When a client is connected to the ZooKeeper server, and the connection is
> lost, it throws a ConnectionLossException.
> The problem is when the connection is back, the client doesn't reconnect
> itself. I can see the following trace on the server
>
> 2010-04-20 17:44:21,526 - INFO  [NIOServerCxn.Factory:>
> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn$Factory@251] - Accepted socket
> connection from /129.183.128.230:60471
> 2010-04-20 17:44:21,526 - INFO  [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@742] - Client attempting to renew
> session0x1281ba54e900005 at /129.183.128.230:60471
> 2010-04-20 17:44:21,527 - INFO  [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1424] - Invalid session
> 0x1281ba54e900005 for client /129.183.128.230:60471, probably expired
> 2010-04-20 17:44:21,527 - INFO  [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1286] - Closed socket connection for
> client /129.183.128.230:60471 which had sessionid 0x1281ba54e900005
>
> The client tries to reconnect with an expired session id.
> Is it possible to configure zookeeper in order that it accepts this
> connection by recreating a new session, or maybe something else that would
> make the reconnection works ?
>
> Thanks in advance for your help
>
> Julien.
>
>
>
>


-- 
With Regards!

Ye, Qian

Re: Client reconnection after a connection loss

Posted by Julien Vey <Ju...@bull.net>.
Thanks for your help Patrick.

I'm already having a look at it.

Julien
> Hi Julien,
>
> take a look at the FAQ for some background:
> http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A3
>
> Basically when your client connects to the server it provides a 
> "timeout" value. If the server doesn't hear from your client within 
> this timeout period (we do heartbeating for you in a background 
> thread, you don't have to worry about this) then it will expire the 
> session.
> http://hadoop.apache.org/zookeeper/docs/current/zookeeperProgrammers.html#ch_zkSessions 
>
>
> You have a watcher for the session - it will be notified both on 
> disconnect but also when/if the session is expired. An expired session 
> is invalid, if this happens you have to create a new session. This is 
> different from a disconnect notification, where you just wait for the 
> client library to reconnect you to the cluster (say you lose 
> connectivity to the server)
>
> Patrick
>
> On 04/21/2010 01:44 AM, Julien Vey wrote:
>> Hi all,
>>
>> I'm currently working with ZooKeeper in CXF D-OSGI and i'm facing a
>> problem that would require your help.
>>
>> When a client is connected to the ZooKeeper server, and the connection
>> is lost, it throws a ConnectionLossException.
>> The problem is when the connection is back, the client doesn't reconnect
>> itself. I can see the following trace on the server
>>
>> 2010-04-20 17:44:21,526 - INFO [NIOServerCxn.Factory:>
>> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn$Factory@251] - Accepted socket
>> connection from /129.183.128.230:60471
>> 2010-04-20 17:44:21,526 - INFO [NIOServerCxn.Factory:
>> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@742] - Client attempting to renew
>> session0x1281ba54e900005 at /129.183.128.230:60471
>> 2010-04-20 17:44:21,527 - INFO [NIOServerCxn.Factory:
>> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1424] - Invalid session
>> 0x1281ba54e900005 for client /129.183.128.230:60471, probably expired
>> 2010-04-20 17:44:21,527 - INFO [NIOServerCxn.Factory:
>> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1286] - Closed socket connection for
>> client /129.183.128.230:60471 which had sessionid 0x1281ba54e900005
>>
>> The client tries to reconnect with an expired session id.
>> Is it possible to configure zookeeper in order that it accepts this
>> connection by recreating a new session, or maybe something else that
>> would make the reconnection works ?
>>
>> Thanks in advance for your help
>>
>> Julien.
>>
>>
>>
>
>


Re: Client reconnection after a connection loss

Posted by Patrick Hunt <ph...@apache.org>.
Hi Julien,

take a look at the FAQ for some background:
http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A3

Basically when your client connects to the server it provides a 
"timeout" value. If the server doesn't hear from your client within this 
timeout period (we do heartbeating for you in a background thread, you 
don't have to worry about this) then it will expire the session.
http://hadoop.apache.org/zookeeper/docs/current/zookeeperProgrammers.html#ch_zkSessions

You have a watcher for the session - it will be notified both on 
disconnect but also when/if the session is expired. An expired session 
is invalid, if this happens you have to create a new session. This is 
different from a disconnect notification, where you just wait for the 
client library to reconnect you to the cluster (say you lose 
connectivity to the server)

Patrick

On 04/21/2010 01:44 AM, Julien Vey wrote:
> Hi all,
>
> I'm currently working with ZooKeeper in CXF D-OSGI and i'm facing a
> problem that would require your help.
>
> When a client is connected to the ZooKeeper server, and the connection
> is lost, it throws a ConnectionLossException.
> The problem is when the connection is back, the client doesn't reconnect
> itself. I can see the following trace on the server
>
> 2010-04-20 17:44:21,526 - INFO [NIOServerCxn.Factory:>
> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn$Factory@251] - Accepted socket
> connection from /129.183.128.230:60471
> 2010-04-20 17:44:21,526 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@742] - Client attempting to renew
> session0x1281ba54e900005 at /129.183.128.230:60471
> 2010-04-20 17:44:21,527 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1424] - Invalid session
> 0x1281ba54e900005 for client /129.183.128.230:60471, probably expired
> 2010-04-20 17:44:21,527 - INFO [NIOServerCxn.Factory:
> 0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1286] - Closed socket connection for
> client /129.183.128.230:60471 which had sessionid 0x1281ba54e900005
>
> The client tries to reconnect with an expired session id.
> Is it possible to configure zookeeper in order that it accepts this
> connection by recreating a new session, or maybe something else that
> would make the reconnection works ?
>
> Thanks in advance for your help
>
> Julien.
>
>
>