mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-14 13:22:27 +00:00
Retry serverinfo query for adding a PC if the request fails with ServiceUnavailableError. Fixes #88
This commit is contained in:
parent
ba7dd31035
commit
4620fa5001
4 changed files with 69 additions and 4 deletions
|
@ -400,6 +400,8 @@ private:
|
||||||
}
|
}
|
||||||
} catch (const GfeHttpResponseException& e) {
|
} catch (const GfeHttpResponseException& e) {
|
||||||
emit pairingCompleted(m_Computer, e.toQString());
|
emit pairingCompleted(m_Computer, e.toQString());
|
||||||
|
} catch (const QtNetworkReplyException& e) {
|
||||||
|
emit pairingCompleted(m_Computer, e.toQString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,6 +454,12 @@ private:
|
||||||
else {
|
else {
|
||||||
emit quitAppFailed(e.toQString());
|
emit quitAppFailed(e.toQString());
|
||||||
}
|
}
|
||||||
|
} catch (const QtNetworkReplyException& e) {
|
||||||
|
{
|
||||||
|
QWriteLocker lock(&m_Computer->lock);
|
||||||
|
m_Computer->pendingQuit = false;
|
||||||
|
}
|
||||||
|
emit quitAppFailed(e.toQString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,8 +542,25 @@ private:
|
||||||
qInfo() << "Processing new PC at" << m_Address << "from" << (m_Mdns ? "mDNS" : "user");
|
qInfo() << "Processing new PC at" << m_Address << "from" << (m_Mdns ? "mDNS" : "user");
|
||||||
|
|
||||||
QString serverInfo;
|
QString serverInfo;
|
||||||
|
try {
|
||||||
|
// 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 {
|
try {
|
||||||
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::VERBOSE);
|
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 (...) {
|
} catch (...) {
|
||||||
if (!m_Mdns) {
|
if (!m_Mdns) {
|
||||||
emit computerAddCompleted(false);
|
emit computerAddCompleted(false);
|
||||||
|
|
|
@ -419,7 +419,7 @@ NvHTTP::openConnection(QUrl baseUrl,
|
||||||
if (logLevel >= NvLogLevel::ERROR) {
|
if (logLevel >= NvLogLevel::ERROR) {
|
||||||
qWarning() << command << " request failed with error " << reply->error();
|
qWarning() << command << " request failed with error " << reply->error();
|
||||||
}
|
}
|
||||||
GfeHttpResponseException exception(reply->error(), reply->errorString());
|
QtNetworkReplyException exception(reply->error(), reply->errorString());
|
||||||
delete reply;
|
delete reply;
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QtNetwork/QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
class NvApp
|
class NvApp
|
||||||
{
|
{
|
||||||
|
@ -52,7 +53,7 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* what() const throw()
|
const char* what() const
|
||||||
{
|
{
|
||||||
return m_StatusMessage.toLatin1();
|
return m_StatusMessage.toLatin1();
|
||||||
}
|
}
|
||||||
|
@ -77,6 +78,41 @@ private:
|
||||||
QString m_StatusMessage;
|
QString m_StatusMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QtNetworkReplyException : public std::exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QtNetworkReplyException(QNetworkReply::NetworkError error, QString errorText) :
|
||||||
|
m_Error(error),
|
||||||
|
m_ErrorText(errorText)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* what() const
|
||||||
|
{
|
||||||
|
return m_ErrorText.toLatin1();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* getErrorText() const
|
||||||
|
{
|
||||||
|
return m_ErrorText.toLatin1();
|
||||||
|
}
|
||||||
|
|
||||||
|
QNetworkReply::NetworkError getError() const
|
||||||
|
{
|
||||||
|
return m_Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString toQString() const
|
||||||
|
{
|
||||||
|
return m_ErrorText + " (Error " + QString::number(m_Error) + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QNetworkReply::NetworkError m_Error;
|
||||||
|
QString m_ErrorText;
|
||||||
|
};
|
||||||
|
|
||||||
class NvHTTP
|
class NvHTTP
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -779,6 +779,10 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||||
emit displayLaunchError(e.toQString());
|
emit displayLaunchError(e.toQString());
|
||||||
s_ActiveSessionSemaphore.release();
|
s_ActiveSessionSemaphore.release();
|
||||||
return;
|
return;
|
||||||
|
} catch (const QtNetworkReplyException& e) {
|
||||||
|
emit displayLaunchError(e.toQString());
|
||||||
|
s_ActiveSessionSemaphore.release();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_assert(!SDL_WasInit(SDL_INIT_VIDEO));
|
SDL_assert(!SDL_WasInit(SDL_INIT_VIDEO));
|
||||||
|
|
Loading…
Reference in a new issue