Hi,
Please find the attached patch for RM #2556: Runtime connection retry loop
timeout
Thanks,
Khushboo
diff --git a/docs/en_US/desktop_deployment.rst b/docs/en_US/desktop_deployment.rst
index 9765c77..745b83f 100644
--- a/docs/en_US/desktop_deployment.rst
+++ b/docs/en_US/desktop_deployment.rst
@@ -73,6 +73,13 @@ semi-colon character, for example:
/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/;/Users/dpage/python-libs/
-The configuration settings are stored using the QSettings class in Qt, which
-will use an INI file on Unix systems, a plist file on Mac OS X, and the registry
-on Windows. The Python Path setting is stored in the ``PythonPath`` key.
\ No newline at end of file
+The configuration settings are stored using the QSettings class in Qt, which
+will use an INI file on Unix systems, a plist file on Mac OS X, and the registry on Windows.
+
+The configuration settings:
+
+Key Description of settings
+-------------------------------------------------------------------------------------
+``PythonPath`` - The Python Path
+``ApplicationPath`` - The Application Path
+``ConnectionTimeout`` - The Connection Timeout in seconds
diff --git a/runtime/pgAdmin4.cpp b/runtime/pgAdmin4.cpp
index 9054e9e..391cf45 100644
--- a/runtime/pgAdmin4.cpp
+++ b/runtime/pgAdmin4.cpp
@@ -340,28 +340,36 @@ int main(int argc, char * argv[])
// Generate the app server URL
QString appServerUrl = QString("http://127.0.0.1:%1/?key=%2").arg(port).arg(key);
+ // Read the server connection timeout from the registry or set the default timeout.
+ QSettings settings;
+ int timeout = settings.value("ConnectionTimeout", 30).toInt();
+
// Now the server should be up, we'll attempt to connect and get a response.
// We'll retry in a loop a few time before aborting if necessary.
- int attempt = 0;
- while (attempt++ < 50)
+
+ QTime endTime = QTime::currentTime().addSecs(timeout);
+ bool alive = false;
+
+ while(QTime::currentTime() <= endTime)
{
- bool alive = PingServer(QUrl(appServerUrl));
+ alive = PingServer(QUrl(appServerUrl));
if (alive)
{
break;
}
- if (attempt == 50)
- {
- splash->finish(NULL);
- QString error(QWidget::tr("The application server could not be contacted."));
- QMessageBox::critical(NULL, QString(QWidget::tr("Fatal Error")), error);
+ delay(200);
+ }
- exit(1);
- }
+ // Attempt to connect one more time in case of a long network timeout while looping
+ if(!alive && !PingServer(QUrl(appServerUrl)))
+ {
+ splash->finish(NULL);
+ QString error(QWidget::tr("The application server could not be contacted."));
+ QMessageBox::critical(NULL, QString(QWidget::tr("Fatal Error")), error);
- delay(200);
+ exit(1);
}
// Create & show the main window