2

I have a very strange problem I create an application that use QNetworkAcessManager to download an HTML page and get the data from this page I release my application to use it on my second laptop on the same wireless connection but it not works.
on my computer, after releasing the app and use windeploy.exe to get all the dll file for this release exe I try to use it on my computer which has QT and developed on it it works fine and get the data in the file.
the problem comes when I use it on another computer the app works but when I press the button to get the data it gets nothing just empty file so any help for this problem this the code which I use normal QNetworkAcessManager code to get HTML page data this code in the button to get the data

manager->clearAccessCache();
manager->clearConnectionCache();
if (reply != nullptr)
    delete reply;
reply = manager->get(QNetworkRequest(QUrl("https://normalpage.html")));
connect(reply, SIGNAL(readyRead()), this, SLOT(readyRead()));
connect(reply, SIGNAL(finished()), this, SLOT(Finish()));

readyread

void MainWindow::readyRead()
{
    data.append(reply->readAll());
}

finish function I get the data of type QByteArray and use it to get the data from it the function is long
I was having this problem for about two months but I was in hurry so I used libcurl with QProcess to get this HTML page data but I now I want to know what cause this problem
update
I used the code in my main.cpp to get all the Qt warnings and errors in a file as mention in the comment by Macias and I get this into the file I used append to the file so I can get all the error it comes and I got some warnings from QSslSocket if anyone can check these warnings and see if it cause the problem as I don't know

Error file

    Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))
)
))
Warning: QSslSocket: cannot call unresolved function SSLv23_client_method ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSL_CTX_new ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSL_library_init ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSLv23_client_method ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSL_CTX_new ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSL_library_init ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))

but in the working computer I got this warrnings

Warning: QSslSocket: cannot resolve SSL_set_alpn_protos ((null):0, (null))
Warning: QSslSocket: cannot resolve SSL_CTX_set_alpn_select_cb ((null):0, (null))
Warning: QSslSocket: cannot resolve SSL_get0_alpn_selected ((null):0, (null))
Warning: QSslSocket: cannot resolve SSL_set_alpn_protos ((null):0, (null))
Warning: QSslSocket: cannot resolve SSL_CTX_set_alpn_select_cb ((null):0, (null))
Warning: QSslSocket: cannot resolve SSL_get0_alpn_selected ((null):0, (null))



Update
when i add the new dll files in the folder excutable file it give me this warrnings

    Warning: QSslSocket: cannot call unresolved function SSLv23_client_method ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSL_CTX_new ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSL_library_init ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))


connect the reply to the error signal

connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(Error(QNetworkReply::NetworkError)));

and the slot is here

    void MainWindow::Error(QNetworkReply::NetworkError Myerror)
{
    qDebug() << "QNetworkReply::NetworkError = " << Myerror;
}


this what i get after connect error signal and the attribute

Warning: QSslSocket: cannot call unresolved function SSLv23_client_method ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSL_CTX_new ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function SSL_library_init ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))
Warning: QSslSocket: cannot call unresolved function ERR_get_error ((null):0, (null))
Debug: QNetworkReply::NetworkError =  QNetworkReply::NetworkError(UnknownNetworkError) ((null):0, (null))
Debug: Attribute in finish slot =  QVariant(Invalid) ((null):0, (null))


when I added the three dlls file to the release folder on my computer which the app i working without them i got this error enter image description here
when i go to the path of C:\AppServ\Apache24\bin and copied this dlls (libeay32.dll and ssleay32.dll) from this folder instead of the others i downloaded from the dll website it finally it works but what is the difference between both in the appchace folder and that are download from website?

thanks in advance

user7179690
  • 1,051
  • 3
  • 17
  • 40
  • I mean curl.exe which I used to download the HTML pages – user7179690 Sep 07 '17 at 21:30
  • I guess that is because of SSL library(I had similar problem), but to be sure redirect your output from console to file, and check the errors (I assume that you don't have any debugger on this laptop). You have example here: https://stackoverflow.com/questions/4954140/how-to-redirect-qdebug-qwarning-qcritical-etc-output – Macias Sep 08 '17 at 01:41

1 Answers1

2

Make sure that you have libeay32.dll, libssl32.dll and ssleay32.dll libs in your deployment folder. If not just copy them next to your *.exe

windeployqt tool does not include these libs.

EDIT:
Your error is propably caused by incopatible version of openSSL library. Version in use at compile time is different from this used at run-time. You can easily check it out. Add these lines after QApplication creation in main.cpp:

qDebug() << "SslSupport: " << QSslSocket::supportsSsl();
qDebug() << "SslLibraryBuildVersion: " << QSslSocket::sslLibraryBuildVersionString();
qDebug() << "SslLibraryRuntimeVersion: " << QSslSocket::sslLibraryVersionString();

You should install and put to your release the most similar to build version.

Macias
  • 657
  • 4
  • 16
  • I past those DLLs to my computer and it didn't work too – user7179690 Sep 12 '17 at 21:51
  • @noname What compiler do you use? Connect http://doc.qt.io/qt-5/qnetworkreply.html#error-1 signal to your `reply` and print to log possible error when arrived. You should also print `QNetworkRequest::HttpStatusCodeAttribute` from http://doc.qt.io/qt-5/qnetworkreply.html#attribute in `finished` slot – Macias Sep 13 '17 at 20:44
  • iam using mingw – user7179690 Sep 13 '17 at 21:13
  • @no name What about `error` signal and `HttpStatusCodeAttribute` ? – Macias Sep 14 '17 at 13:46
  • I can't print error signal as I try this in the code but it give me an error QNetworkReply::NetworkError Myerror Myerror.errorString(); in the signal of error of reply but it give me an error request for member 'errorString' in 'Myerror', which is of non-class type 'QNetworkReply::NetworkError' Myerror.errorString(); – user7179690 Sep 15 '17 at 01:05
  • connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(Error(QNetworkReply::NetworkError))); void MainWindow::Error(QNetworkReply::NetworkError Myerror) { qDebug() << "QNetworkReply::NetworkError = " << Myerror.errorString(); } – user7179690 Sep 15 '17 at 03:06
  • I add this to the question – user7179690 Sep 15 '17 at 03:06
  • 2
    @no name It gives you an error because `QNetworkReply::NetworkError` is enum, not class, just print it: `qDebug() << "Error: " << Myerror;` – Macias Sep 15 '17 at 03:15
  • the question updated with what I got when I use the error signal – user7179690 Sep 15 '17 at 10:44
  • @no name There is no HTTP response with code 0, so I'm sure that you're doing something wrong. Give some more code please (paste or better link to repo with minimal project where error occurs), because I can't reproduce your error and I see that you are not fluent with Qt programming because you making basic mistakes. If I find an issue I will explain you why etc :) – Macias Sep 16 '17 at 04:32
  • 1
    if there is an error in code i think it will not work on my computer anyway here is the code i upload it to my google drive https://drive.google.com/file/d/0B5rlQZmglfhEVUlEcGxmYVdvTWs/view?usp=sharing – user7179690 Sep 17 '17 at 00:15
  • @noname Can you show your release package with all subdirectories? – Macias Sep 19 '17 at 18:37
  • thank you for your help I will take this as the solution to my question I update the question with what I did – user7179690 Sep 19 '17 at 19:15