What is the right way of reconnecting upon initial connect error?

If couchbase server is down at the time of first lcb_connect call then libcouchbase will not automatically reconnect.

Right now I use workaround, by issuing another call to lcb_connect after some time (when server is possibly back again). It helps, but there are problems:

  1. No clear way to know if manual reconnect should be performed. Using configuration callback helps - if we get it called back then libcouchbase will reconnect automatically.

  2. Memory leak when using libev plugin. instance->event is not destroyed and being overwritten on every lcb_connect call. The only way seem to be to destroy lcb_t instance, but it’s not very convenient.

What is the right way to manage reconnects if initial connection have failed?

Good question; I just run into the same memory leak you mentioned using libevent.