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 Failed to make connection with https server
Qt 6.11 is out! See what's new in the release blog

QNetworkAccessManager Failed to make connection with https server

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.8k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi all,

    I am working on QNetworkAccessManager and I am stuck with it. I have developed my code in QT 4.7.4. and it is working fine on 4.7.4. But when I update from QT4.7.4 to 4.8.0. then my connection failed and finished signal is called with timeout. For more information my project is also working fine on Mac OS X 10.7 with QT 4.8.0. It throws sslError and I simply ignore it. But on Windows no sslError, no error through QNetworkReply. I have installed openSSl and placed lib files in Windows/system directory. By doing this I am able to hit some "https" servers.
    I can communicate with some "https" like gmail servers but it failed on server where I want.

    Please help me out.

    Thanks in advance :).

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

      For more information: Below is my code snippet:
      @
      ServerTest::ServerTest()
      {
      manager = new QNetworkAccessManager(this);
      QNetworkConfigurationManager manager1;
      manager->setConfiguration(manager1.defaultConfiguration());
      req.setUrl(QUrl("https://mytestserver.com"));
      req.setRawHeader("Content-Type", "application/json+batch");
      QByteArray postData("Hello World");
      QNetworkReply reply= manager->post(req, postData);
      connect(reply , SIGNAL(error(QNetworkReply::NetworkError)) , this , SLOT(error(QNetworkReply::NetworkError)));
      connect(manager , SIGNAL(sslErrors(QNetworkReply
      ,QList<QSslError>)) , this ,SLOT(sslErrors(QNetworkReply*,const QList<QSslError> &)));
      connect(manager , SIGNAL(finished(QNetworkReply*)) , this , SLOT(finished(QNetworkReply*)));
      }
      void ServerTest::sslErrors(QNetworkReply reply, const QList<QSslError> &errors) {
      qDebug("ssl error" + errors.length());
      reply->ignoreSslErrors(errors);
      }
      void ServerTest::finished(QNetworkReply reply) {
      qDebug("
      ** Finished **** ");
      QByteArray data = reply->readAll();
      qDebug(data);
      }
      void ServerTest::error(QNetworkReply::NetworkError code) {
      qDebug("Error "+code);
      }
      @

      After 4-5 minutes it only prints "***** finished **********".

      But when I run same project on QT 4.7.4 then I received following out put:
      ssl error
      Finished signal with reply->readAll.
      {"success":false,"config":{"stop_submitting":false,"submit_interval":5,"submit_count":1},"success_count":0,"fail_count":1}

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        I have added "code wrappings,":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 please remember next time.

        Vote the answer(s) that helped you to solve your issue(s)

        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