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. QNetworkAcessManager Not work in release mode on different computers

QNetworkAcessManager Not work in release mode on different computers

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 1.7k Views 3 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.
  • AmrCoderA Offline
    AmrCoderA Offline
    AmrCoder
    wrote on last edited by AmrCoder
    #1

    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
    Update
    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 use this code in my main to get all the Qt Warnings and errors to check what makes this problem

    #include "mainwindow.h"
    #include <QApplication>
    
    #include <QtGlobal>
    #include <stdio.h>
    #include <stdlib.h>
    
    void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
    {
        QByteArray localMsg = msg.toLocal8Bit();
        FILE *file;
        file = fopen("error.txt", "a");
        switch (type) {
        case QtDebugMsg:
            fprintf(file, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
            break;
        case QtInfoMsg:
            fprintf(file, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
            break;
        case QtWarningMsg:
            fprintf(file, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
            break;
        case QtCriticalMsg:
            fprintf(file, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
            break;
        case QtFatalMsg:
            fprintf(file, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
            abort();
        }
    }
    
    int main(int argc, char *argv[])
    {
        qInstallMessageHandler(myMessageOutput);
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    

    the error file on the not working computer gives me this 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 on my working computer it gives me this

    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))
    

    if anyone can check these warnings and see if it cause the problem as I don't know
    thanks in advance

    VRoninV 1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Maybe it's the firewall or something similar.

      1 Reply Last reply
      0
      • AmrCoderA Offline
        AmrCoderA Offline
        AmrCoder
        wrote on last edited by
        #3

        they are Turned off on both computers

        1 Reply Last reply
        0
        • AmrCoderA AmrCoder

          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
          Update
          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 use this code in my main to get all the Qt Warnings and errors to check what makes this problem

          #include "mainwindow.h"
          #include <QApplication>
          
          #include <QtGlobal>
          #include <stdio.h>
          #include <stdlib.h>
          
          void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
          {
              QByteArray localMsg = msg.toLocal8Bit();
              FILE *file;
              file = fopen("error.txt", "a");
              switch (type) {
              case QtDebugMsg:
                  fprintf(file, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  break;
              case QtInfoMsg:
                  fprintf(file, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  break;
              case QtWarningMsg:
                  fprintf(file, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  break;
              case QtCriticalMsg:
                  fprintf(file, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  break;
              case QtFatalMsg:
                  fprintf(file, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
                  abort();
              }
          }
          
          int main(int argc, char *argv[])
          {
              qInstallMessageHandler(myMessageOutput);
              QApplication a(argc, argv);
              MainWindow w;
              w.show();
          
              return a.exec();
          }
          

          the error file on the not working computer gives me this 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 on my working computer it gives me this

          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))
          

          if anyone can check these warnings and see if it cause the problem as I don't know
          thanks in advance

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          @AmrCoder said in QNetworkAcessManager Not work in release mode on different computers:

          QUrl("https

          Did you remember to deploy OpenSSL?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0
          • AmrCoderA Offline
            AmrCoderA Offline
            AmrCoder
            wrote on last edited by AmrCoder
            #5

            @VRonin no, and how can I do this when I release an app in Qt i only use windeployqt.exe to take all needed DLLs for the app to work if there another method to make qnetworkacessmanager work tell me how

            1 Reply Last reply
            0
            • AmrCoderA Offline
              AmrCoderA Offline
              AmrCoder
              wrote on last edited by
              #6

              @VRonin I copied this two files libeay32 and ssleay32 dlls to the folder and it not work too

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #7

                Could you change the code so it goes on a http (i.e. not https) page and see if it works there?

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                0
                • AmrCoderA Offline
                  AmrCoderA Offline
                  AmrCoder
                  wrote on last edited by
                  #8

                  @VRonin this time when I tried HTTP it not worked even on my computer

                  1 Reply Last reply
                  0
                  • lorn.potterL Offline
                    lorn.potterL Offline
                    lorn.potter
                    wrote on last edited by
                    #9

                    You didn't mention which platform this was on, but from one of your replies, I take it to be windows.
                    As well, which version of Qt, and did you compile it yourself?

                    Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
                    Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

                    1 Reply Last reply
                    0
                    • AmrCoderA Offline
                      AmrCoderA Offline
                      AmrCoder
                      wrote on last edited by
                      #10

                      Iam using windows 10
                      Qt 5.9.1
                      yes I compile it my self the computer which has Qt the QNetworkAcessManager Give me an output as I mention and it works in release mode too when I release the app and put all dlls using winddeploy.exe
                      and use the app without QT it works but when I try on another computer it didn't work or give me any data

                      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