Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KazooClient bug? connection time-out, but not retry another zk server. #205

Closed
catmonkeylee opened this issue May 14, 2014 · 5 comments
Closed

Comments

@catmonkeylee
Copy link

My question is that:
when client connect to yahoo.com:80, there is a timeout exception was throwed, But it didn't retry connect to 127.0.0.1:2181( this is my real zk server). Anybody can help me? thanks.

source code:

import logging
logging.basicConfig(level=logging.DEBUG)
from kazoo.client import KazooClient
from kazoo.retry import KazooRetry
_retry = KazooRetry(max_tries=1000, delay=0.5, backoff=2)
_zk = KazooClient(hosts="yahoo.com:80,127.0.0.1:2181", logger=logging, read_only=True, timeout=30, connection_retry=_retry)
_zk.start()

_zk.stop()

log:

DEBUG:root:ZK loop started
DEBUG:root:Skipping state change
INFO:root:Connecting to yahoo.com:80
DEBUG:root: Using session_id: None session_passwd: 00000000000000000000000000000000
INFO:root:Sending request(xid=None): Connect(protocol_version=0, last_zxid_seen=0, time_out=30000, session_id=0, passwd='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', read_only=True)
WARNING:root:Connection dropped: socket connection broken
DEBUG:root:Connection stopped
Traceback (most recent call last):
File "/tmp/1.py", line 7, in
_zk.start()
File "/home/s/apps/wdshopping/python/lib/python2.7/site-packages/kazoo-1.2.1-py2.7.egg/kazoo/client.py", line 476, in start
raise self.handler.timeout_exception("Connection time-out")

kazoo.handlers.threading.TimeoutError: Connection time-out

@harlowja
Copy link
Contributor

harlowja commented Jun 7, 2014

Yahoo.com:80 (niceeee, haha)

@bbangert
Copy link
Member

This should be submitted to python-zk mail list if you have a question. I don't think you should try to connect to webservers offhand.

@genisd
Copy link

genisd commented May 31, 2017

i'm facing this as well. did you ever figure it out?

@trobinsonpp
Copy link

Try setting the kazoo.client.KazooClient.start timeout higher than the kazoo.client.KazooClient timeout.

For your example:
_zk.start(timeout=40)

@graysonchao
Copy link

^^^ Doing the above can help, but might mask an issue with timeouts once the connection is established. Kazoo seems to use the client session timeout (the one in kazoo.client.KazooClient) for each attempted TCP connection before negotiating a session, but later on, it divides this number by the number of hosts in the ensemble to decide on its internal "connect timeout" (e.g. how long to wait before a write request or a reconnect times out.)

So, if you set a low timeout in kazoo.client.KazooClient.__init__, you might run into issues where reconnecting or submitting requests times out much faster than you expected. If you set them equal or have the __init__ timeout higher, then you can burn your entire KazooClient.start timeout on a single unresponsive host.

I'm opening a separate issue to check whether this is intended behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants