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. Qt Https request with openssl - No response

Qt Https request with openssl - No response

Scheduled Pinned Locked Moved Solved General and Desktop
qtnetworkopensslhttps post
3 Posts 2 Posters 1.3k 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.
  • T Offline
    T Offline
    Thanni
    wrote on 1 Dec 2018, 04:03 last edited by
    #1

    Hey guys,
    I'm trying to get my problem solved the last days, but I can't. I've read many forums but unfortunately I've found no solution, maybe someone can help me.

    My intention is to communicate with an webservice. The code should work, but when I'm executing it, I don't get any answer. I should receive some information about my request, but there is no response. Did I miss something? I've also included some openssl libraries. In the .pro file as well as on the system. At the moment I'm running windows 10 with Qt 5.11 on it.
    I've read about some issues according to the incompatibility between Qt 5.11 and openssl 1.1.0, so I've already installed 1.0.2. But nothing...

    Here is my code for the request:

    Testing::Testing(QObject *parent) :
    QObject (parent)
    {
    connect(&manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    
    // no proxy
    QNetworkProxyFactory::setUseSystemConfiguration(true);
    manager.setProxy(QNetworkProxy(QNetworkProxy::NoProxy));
    QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
    }
    
    void Testing::doRequest()
    {
    // request
    QString requestURL = QString("https://account.radiobridge.io/account/");
    QUrl url(requestURL);
    QNetworkRequest request;
    request.setUrl(url);
    request.setRawHeader(QByteArray("accept"),QByteArray("application/json"));
    
    QNetworkReply* currentReply = manager.get(request);  // GET
    }
    
    
    void Testing::replyFinished(QNetworkReply *reply)
    {
    if (reply->error())
    {
        qWarning() << "ErrorNo: " << reply->error() << "for url: " << reply->url().toString();
        qDebug() << "Request failed, " << reply->errorString();
    }else
    {
        qDebug() << "Content: " << reply->readAll();
    }
    }
    
    
    int main(int argc, char *argv[])
    {
    Testing t;
    t.doRequest();
    }
    

    Here is my .pro file:

    QT      += core
    QT      += network
    QT      -= gui
    
    HEADERS += \
    accountmanager.h \
    radiostationlist.h \
    radiostation.h \
    testing.h
    
    SOURCES += \
    demo.cpp \
    accountmanager.cpp \
    radiostationlist.cpp \
    radiostation.cpp \
    testing.cpp
    
    LIBS += E:/Programme/OpenSSL-Win64/lib/libeay32.lib
    LIBS += E:/Programme/OpenSSL-Win64/lib/ssleay32.lib
    

    That's the console output:

    C:\Users\thanh\Desktop\build-Alpini-Desktop_Qt_5_11_2_MinGW_32bit-Debug\debug\Alpini...
    C:/Users/thanh/Desktop/build-Alpini-Desktop_Qt_5_11_2_MinGW_32bit-Debug/debug/Alpini wurde mit dem 
    Rückgabewert 0 beendet
    

    Hopefully, there is somebody who can help me.

    Best regards,
    Thanni

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 1 Dec 2018, 04:14 last edited by
      #2

      Can create the QApplication object & Start the event loop like follows ?

      int main(int argc, char *argv[])
      {
      QApplication a(argc,argv)
      Testing t;
      t.doRequest();
      a.exec()
      }

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      3
      • T Offline
        T Offline
        Thanni
        wrote on 1 Dec 2018, 11:19 last edited by
        #3

        It wooooorked, thank you so muuuuch :)

        1 Reply Last reply
        0

        2/3

        1 Dec 2018, 04:14

        • Login

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