Acting on a failed connect()
rberlich opened this issue · comments
Hi again,
from what I understand, the client-side connect() call has the sole option to throw from within the onerror() call to let the audience know that something went wrong. Any chance of returning a boolean or giving access to the error code through a reference argument ?
All clients and the server will be started in a compute cluster in my case, usually through some submission script and via a batch queue. It is not guaranteed that the server is available immediately. Hence I'd like to loop on the connect() call for a number of times on the client side, so the server has time to start up.
This would be easiest if connect() would return a bool, something like
while(!connect() && nConnectionAttempts++ < maxConnectionAttempts);
Thanks and Best Regards,
Beet
Hmmm, o.k., connect() is usually not called directly, instead one uses start(). However, this also returns void, so a loop would not be possible.
You would have to perform this check in onerror, and run Client::start again after an error is received.
In your case, you probably have to call Client::stop before calling Client::start again.