loolwsd: test: retry connection failures

Change-Id: Iff2cf05bf755ba0df08304af9f2cc6c488e18428
Reviewed-on: https://gerrit.libreoffice.org/30885
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2016-11-15 16:22:02 -05:00 committed by Ashod Nakashian
parent 0cc57c643d
commit 78be068a7f

View file

@ -348,15 +348,24 @@ connectLOKit(const Poco::URI& uri,
int retries = 10;
do
{
std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(uri));
auto ws = std::make_shared<LOOLWebSocket>(*session, request, response);
const auto expected_response = "statusindicator: ready";
if (getResponseString(ws, expected_response, name) == expected_response)
try
{
return ws;
std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(uri));
auto ws = std::make_shared<LOOLWebSocket>(*session, request, response);
const auto expected_response = "statusindicator: ready";
if (getResponseString(ws, expected_response, name) == expected_response)
{
return ws;
}
std::cerr << (11 - retries);
}
catch (const std::exception& ex)
{
std::cerr << std::endl << "Error connecting: " << ex.what() << std::endl;
}
std::cerr << (11 - retries);
std::this_thread::sleep_for(std::chrono::milliseconds(POLL_TIMEOUT_MS));
}
while (retries--);