You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, January 19th 2015, 11:43pm

QNetworkAccessManager Error Code 99; Only on Some Systems…

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:

Source code

1
MainNetConnector = new QNetworkAccessManager(this);


The function that starts the test:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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);

	}

}


And the error-handling function:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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);

}