Merge pull request #4856 from bunnei/webservice-socket-error

web_service: web_backend: Handle socket errors with GenericRequest.
This commit is contained in:
LC 2020-10-28 20:46:28 -04:00 committed by GitHub
commit c20569ebdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -65,6 +65,17 @@ struct Client::Impl {
if (cli == nullptr) {
cli = std::make_unique<httplib::Client>(host.c_str());
}
if (!cli->is_valid()) {
LOG_ERROR(WebService, "Client is invalid, skipping request!");
return {};
}
if (!cli->is_socket_open()) {
LOG_ERROR(WebService, "Failed to open socket, skipping request!");
return {};
}
cli->set_connection_timeout(TIMEOUT_SECONDS);
cli->set_read_timeout(TIMEOUT_SECONDS);
cli->set_write_timeout(TIMEOUT_SECONDS);