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: UnknownNetworkError in Windows
Forum Updated to NodeBB v4.3 + New Features

QNetworkAccessManager: UnknownNetworkError in Windows

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 599 Views
  • 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.
  • A Offline
    A Offline
    AxelVienna
    wrote on 11 Aug 2021, 09:10 last edited by
    #1

    Hi,
    the code listed below works well under Linux and produces an unknown network error under Windows.
    I have installed the latest openssl on the Windows box.
    Help is highly appreciated, thanks in advance.
    Brgds
    Axel

        const string url = "https://mySecretUrl.at/apikey";
    
        QNetworkAccessManager am;
        QNetworkRequest nr(QUrl(url.c_str()));
        nr.setRawHeader("apikey",userkey.c_str());
        QNetworkReply* r = am.get(nr);
    
        QEventLoop loop;
        QObject::connect(r, &QNetworkReply::finished, &loop, &QEventLoop::quit);
        loop.exec();
        resultBody = QString::fromUtf8(r->readAll()).toStdString();
        bool ret = (r->error()==QNetworkReply::NoError);
        auto error = r->error();
        delete r;
    

    C++ and Python walk into a bar. C++ reuses the first glass.

    J 1 Reply Last reply 11 Aug 2021, 09:13
    0
    • A AxelVienna
      11 Aug 2021, 09:10

      Hi,
      the code listed below works well under Linux and produces an unknown network error under Windows.
      I have installed the latest openssl on the Windows box.
      Help is highly appreciated, thanks in advance.
      Brgds
      Axel

          const string url = "https://mySecretUrl.at/apikey";
      
          QNetworkAccessManager am;
          QNetworkRequest nr(QUrl(url.c_str()));
          nr.setRawHeader("apikey",userkey.c_str());
          QNetworkReply* r = am.get(nr);
      
          QEventLoop loop;
          QObject::connect(r, &QNetworkReply::finished, &loop, &QEventLoop::quit);
          loop.exec();
          resultBody = QString::fromUtf8(r->readAll()).toStdString();
          bool ret = (r->error()==QNetworkReply::NoError);
          auto error = r->error();
          delete r;
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 11 Aug 2021, 09:13 last edited by jsulm 8 Nov 2021, 09:45
      #2

      @AxelVienna Please add error handling.Especially https://doc.qt.io/qt-5/qnetworkaccessmanager.html#sslErrors , https://doc.qt.io/qt-5/qnetworkreply.html#sslErrors and https://doc.qt.io/qt-5/qnetworkreply.html#errorOccurred
      You probably don't have SSL libs (you're accessing a HTTPS URL).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • A Offline
        A Offline
        AxelVienna
        wrote on 11 Aug 2021, 12:07 last edited by
        #3

        @jsulm: Thanks for pointing to this direction.
        Installing OpenSSL from https://slproweb.com/download/Win64OpenSSL-1_1_1k.msi did the trick.
        My problem was that I had installed the light install version which obviously has no headers included.
        Issue solved.

        C++ and Python walk into a bar. C++ reuses the first glass.

        1 Reply Last reply
        0

        1/3

        11 Aug 2021, 09:10

        • Login

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