Retry serverinfo query for adding a PC if the request fails with ServiceUnavailableError. Fixes #88

This commit is contained in:
Cameron Gutman
2018-09-29 03:01:49 -07:00
parent ba7dd31035
commit 4620fa5001
4 changed files with 69 additions and 4 deletions

View File

@@ -400,6 +400,8 @@ private:
}
} catch (const GfeHttpResponseException& e) {
emit pairingCompleted(m_Computer, e.toQString());
} catch (const QtNetworkReplyException& e) {
emit pairingCompleted(m_Computer, e.toQString());
}
}
@@ -452,6 +454,12 @@ private:
else {
emit quitAppFailed(e.toQString());
}
} catch (const QtNetworkReplyException& e) {
{
QWriteLocker lock(&m_Computer->lock);
m_Computer->pendingQuit = false;
}
emit quitAppFailed(e.toQString());
}
}
@@ -535,7 +543,24 @@ private:
QString serverInfo;
try {
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::VERBOSE);
// There's a race condition between GameStream servers reporting presence over
// mDNS and the HTTPS server being ready to respond to our queries. To work
// around this issue, we will issue the request again after a few seconds if
// we see a ServiceUnavailableError error.
try {
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::VERBOSE);
} catch (const QtNetworkReplyException& e) {
if (e.getError() == QNetworkReply::ServiceUnavailableError) {
qWarning() << "Retrying request in 5 seconds after ServiceUnavailableError";
QThread::sleep(5);
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::VERBOSE);
qInfo() << "Retry successful";
}
else {
// Rethrow other errors
throw e;
}
}
} catch (...) {
if (!m_Mdns) {
emit computerAddCompleted(false);