Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkAccessManager Error Code 99; Only on Some Systems...
Forum Updated to NodeBB v4.3 + New Features

QNetworkAccessManager Error Code 99; Only on Some Systems...

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tmason101
    wrote on last edited by
    #1

    Hello,

    When using QNetworkAccessManager I get a strange error that only occurs on some systems but not others.

    See below for the code. The test below connects to an SSL-based site.

    I have OpenSSL DLLs (libeay32.dll and ssleay32.dll) on the client systems in the same directory as my application but the error still occurs.

    The error code is (99) - Unknown Network Error.

    What causes this error on some systems but not others?

    What can I do to fix?

    Thank you for your time.

    In the constructor of the application:

    @
    MainNetConnector = new QNetworkAccessManager(this);
    @

    The function that starts the test
    @

    void QTBasicWidget::performNetworkTest() {

    QMessageBox::StandardButton RequestNetworkTest;

    RequestNetworkTest = QMessageBox::information(this, "Would you like to initiate a network test?",
    "Would you like to perform a network test?\n\nThe application will test the network for connectivity to and from the licensing server specified.\n\nResults will be displayed in the 'Log' tab.",
    QMessageBox::Yes | QMessageBox::No);

    QNetworkRequest req;

    QByteArray postData;

    QNetworkReply* reply;

    switch (RequestNetworkTest) {

    case QMessageBox::Yes:

    LoggingWidget->logText(tr("Beginning the network test."));

    if (UseSecuredURL) {

    req.setUrl(QUrl(SecureURL + "testconnection.php"));

    LoggingWidget->logText(tr("Connecting to secure URL: ") + SecureURL + tr("testconnection.php"));

    }
    else {

    req.setUrl(QUrl(UnsecureURL + "testconnection.php"));

    LoggingWidget->logText(tr("Connecting to unsecure URL: ") + UnsecureURL + tr("testconnection.php"));

    }

    MainNetConnector->setCookieJar(new QNetworkCookieJar(MainNetConnector));

    LoggingWidget->logText(tr("Cookie jar prepared for data to send."));

    reply = MainNetConnector->post(req, postData);

    LoggingWidget->logText(tr("Data sent."));

    connect(reply, &QNetworkReply::finished, this, &QTBasicWidget::processTestResults);
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
    this, SLOT(networkError(QNetworkReply::NetworkError)));

    if (TestingTimer) {

    TestingTimer->stop();
    TestingTimer->deleteLater();
    TestingTimer = NULL;

    }

    TestingTimer = new QTimer(this);
    connect(TestingTimer, SIGNAL(timeout()), this, SLOT(onDelayedNetworkTestReponse()));
    TestingTimer->start(5000);

    break;

    case QMessageBox::No:

    QMessageBox::information(this, "Test cancelled.",
    "Network test cancelled.",
    QMessageBox::Ok);

    break;

    default:

    QMessageBox::information(this, "Test cancelled.",
    "Network test cancelled.",
    QMessageBox::Ok);

    break;

    }

    }
    @

    The function that received the results of the test:
    @void QTBasicWidget::processTestResults() {

    if (TestingTimer) {

    TestingTimer->stop();
    TestingTimer->deleteLater();
    TestingTimer = NULL;

    }

    LoggingWidget->logText(tr("Reply received."));
    auto reply = qobject_cast< QNetworkReply *>(sender());
    QByteArray bytes = reply->readAll();
    QString str = QString::fromUtf8(bytes.data(), bytes.size());

    LoggingWidget->logText(tr("Raw data from reply: ") + str);

    GLint statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();

    LoggingWidget->logText(tr("Reply status code: ") + QString::number(statusCode));

    if (statusCode == 200) {

    QMessageBox::StandardButton NetworkTestResults;

    NetworkTestResults = QMessageBox::information(this, "Test succeeded!.",
    "Network test succeeded.",
    QMessageBox::Ok);

    }
    else {

    QMessageBox::StandardButton NetworkTestFailed;

    NetworkTestFailed = QMessageBox::critical(this, "Test failed!.",
    "Network test failed.",
    QMessageBox::Ok);

    }

    }
    @

    Error handling function:

    @
    void QTBasicWidget::networkError(QNetworkReply::NetworkError err) {

    if (CurrentlyDebugging) {

    LoggingWidget->logText(tr("Network error. Error code is: ") + QString::number(err));

    }

    QMessageBox::StandardButton CriticalMessageBox;

    CriticalMessageBox = QMessageBox::critical(this, tr("Licensing Server Error"),
    tr("Specific error code was (") + QString::number(err) + tr(")"), QMessageBox::Ok);

    }
    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved