jurmous / etcd4j

Java / Netty client for etcd, the highly-available key value store for shared configuration and service discovery.
Apache License 2.0
267 stars 83 forks source link

Timeout or connection timeout is not working. #179

Closed sarvandhoot closed 6 years ago

sarvandhoot commented 6 years ago

In case if ETCD is down connection is not getting timed out.

I have used both put and get API and it waits for indefinite time for making the timeout.

I have used the version 2.15.0 and 2.16.0

Please suggest.

-Sarvan

lburgazzoli commented 6 years ago

did you properly configure retry ?

sarvandhoot commented 6 years ago

Hi,

Best of my knowledge -

This is how I am creating the client.

EtcdNettyConfig config = new EtcdNettyConfig(); config.setConnectTimeout(10); EtcdNettyClient nettyClient = new EtcdNettyClient(config, URI.create(etcduri)); etcdClient = new EtcdClient(nettyClient);

and

get request -

// get the ResponsePromise // get the value from ResponsePromise EtcdKeyGetRequest getRequest = client.get(key).timeout(1, TimeUnit.SECONDS); try{ return getRequest.send(); }catch(IOException e){ try{ // Retry again once return getRequest.send(); }catch(IOException e1){ throw e1; }catch(Exception e1){ throw e1; } }catch(Exception e){ throw e; }

put request -

// put the key-value EtcdResponsePromise promise = client.put(key, value).timeout(1, TimeUnit.SECONDS).send(); // Call the promise in a blocking way try{ EtcdKeysResponse response = promise.get(); // Do something with response }catch(EtcdException e){ if(e.isErrorCode(EtcdErrorCode.NodeExist)){ throw new RestException("error occured"); } // Do something with the exception returned by etcd }catch(IOException | TimeoutException e){ throw new RestException("Timeout error"); }

Regards, Sarvan

On Fri, Aug 10, 2018 at 2:50 PM Luca Burgazzoli notifications@github.com wrote:

did you properly configure retry ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jurmous/etcd4j/issues/179#issuecomment-412027839, or mute the thread https://github.com/notifications/unsubscribe-auth/AEeVgwvOV1FAvy8-RjN8Lc6vM6vBMO78ks5uPVBogaJpZM4V33Qw .

lburgazzoli commented 6 years ago

see: https://github.com/jurmous/etcd4j#set-a-retry-policy

sarvandhoot commented 6 years ago

Hi,

Is it necessary to use the retry for the timeout process.

Thanks its working now.

lburgazzoli commented 6 years ago

yes it is, by default it retries indefinitively