jplana / python-etcd

A python client for etcd
Other
522 stars 210 forks source link

SRV srv_domain parameter is ignored #276

Closed zloyded closed 1 year ago

zloyded commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

i see dns resolver problems with VPN

zloyded commented 3 years ago

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 commented 3 years ago

Hello?

lavagetto commented 1 year ago

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