python-etcd icon indicating copy to clipboard operation
python-etcd copied to clipboard

SRV srv_domain parameter is ignored

Open zloyded opened this issue 4 years ago • 4 comments

Problems with SRV discovery connect:

import etcd

cl = etcd.Client(srv_domain='my_domain.zone')
cl.stats
>>
Connection to etcd failed due to MaxRetryError("HTTPConnectionPool(host='127.0.0.1', port=4001): Max retries exceeded with url: /v2/stats/self (Caused by ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))")

why attempt connect to localhost?!

zloyded avatar Feb 11 '21 12:02 zloyded

in __init__ of Client can see defaults

            self,
            host='127.0.0.1',
            port=4001,
...

Why it here? If i need service discovery this code would be ignored, and will try to init connection by host in the defaults!!!

zloyded avatar Feb 12 '21 07:02 zloyded

i see dns resolver problems with VPN

zloyded avatar Feb 12 '21 08:02 zloyded

okay! I have correct resolve my SRV record in Python:

srv_domain='_etcd-client._tcp.my_sub.my_company.my_zone'
q = dns.resolver.query(srv_domain, 'SRV')
for h in q:
   print(h.target.to_text(omit_final_dot=True), h.port)
0etcd0002.e.my_co.my_z 2379
0etcd0003.e.my_co.my_z 2379
1etcd0002.e.my_co.my_z 2379

and try to discover

ec = etcd.Client(srv_domain=srv_domain)
ec.stats
>>
EtcdConnectionFailed: Connection to etcd failed due to MaxRetryError("HTTPConnectionPool(host='127.0.0.1', port=4001): Max retries exceeded with url: /v2/stats/self (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f1d982b4910>: Failed to establish a new connection: [Errno 111] Connection refused'))")

zloyded avatar Feb 26 '21 08:02 zloyded

Hello?

zloyded avatar Mar 10 '21 08:03 zloyded

IF you correctly read the documentation you would know what you're doing wrong.

lavagetto avatar Oct 30 '23 06:10 lavagetto