kragniz / python-etcd3

Python client for the etcd API v3
Apache License 2.0
430 stars 184 forks source link

client support reconnection ? #580

Open meimeitou opened 6 years ago

meimeitou commented 6 years ago

connected to server and few minutes later call client.get('/xxx'), got error:

grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
    status = StatusCode.UNAUTHENTICATED
    details = "etcdserver: invalid auth token"
    debug_error_string = "{"created":"@1540208787.330001000","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1099,"grpc_message":"etcdserver: invalid auth token","grpc_status":16}"
zyi1992 commented 5 years ago

I got the same problem, seems you need to add yourself's reconnection code.

achimnol commented 5 years ago

I have the same problem when using authentication. etcd's auth token expires after about 5 minutes, and after then, all API calls fail.

achimnol commented 5 years ago

I've ended up writing an adaptor that reconnects & reauthenticates with specific grpc errors. https://github.com/lablup/backend.ai-common/commit/0526a3f7a2800966f5350cbac264561d0b657f8e

Note: When initializing the etcd3 client, the first authentication routine does not apply _handle_errors() so I had to catch "UNAVAILABLE" exception instead of etcd3.exceptions.ConnectionFailedError.