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. Issue with FTP using QNetworkAccessManager
Qt 6.11 is out! See what's new in the release blog

Issue with FTP using QNetworkAccessManager

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 1.3k Views 2 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.
  • C Offline
    C Offline
    CLBSII
    wrote on last edited by
    #1

    Hi evereyone,

    I want to use QNetworkAccessManager in order to download a file from a FTP server. Basicly, I use the following code according to the documentation:

    myNetworkManager = new QNetworkAccessManager(this);
    QUrl url("ftp://FTP_server:1234@192.168.1.62:2121/file_1.png");
    myNetworkRequest.setUrl(url);
    myNetworkReply = myNetworkManager->get(myNetworkRequest);
    

    It gives me this error:

    qt.network.ssl: No functional TLS backend was found
    qt.network.ssl: No functional TLS backend was found
    qt.network.ssl: No functional TLS backend was found
    qt.network.ssl: No TLS backend is available
    

    After some research, it appears the openSSL library is not include in QT. I found a bunch of tutorial explaining how to install it, but it not seems so easy.

    So is this the only solution, or do I do something wrong using QNetworkAccessManager for my FTP request ?

    Thanks all.

    raven-worxR 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #10

      Yes, it's one way to implement it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • C CLBSII

        Hi evereyone,

        I want to use QNetworkAccessManager in order to download a file from a FTP server. Basicly, I use the following code according to the documentation:

        myNetworkManager = new QNetworkAccessManager(this);
        QUrl url("ftp://FTP_server:1234@192.168.1.62:2121/file_1.png");
        myNetworkRequest.setUrl(url);
        myNetworkReply = myNetworkManager->get(myNetworkRequest);
        

        It gives me this error:

        qt.network.ssl: No functional TLS backend was found
        qt.network.ssl: No functional TLS backend was found
        qt.network.ssl: No functional TLS backend was found
        qt.network.ssl: No TLS backend is available
        

        After some research, it appears the openSSL library is not include in QT. I found a bunch of tutorial explaining how to install it, but it not seems so easy.

        So is this the only solution, or do I do something wrong using QNetworkAccessManager for my FTP request ?

        Thanks all.

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #2

        @CLBSII
        what type of FTP server is this?
        normally FTP is unencrypted. But FTP over SSL first connects via FTP and then switches to a secure encrypted port.

        Installation of OpenSSL libs is actually pretty easy.
        Simply copy the 2 OpenSSL libs either next to your executable or ensure that they are in the PATH env variable (assuming you are on Windows)
        https://wiki.openssl.org/index.php/Binaries
        or install it via the Qt MaintenanceTool

        What Qt version btw?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • C Offline
          C Offline
          CLBSII
          wrote on last edited by
          #3

          @raven-worx
          To be honest, my FTP server is running on a distant computer using this Python Library, so I'm not sure for the type.

          Well it seems you was right, I successfully installed the OpenSSL lib following your link and the error disappeared. Thanks for helping (and yes I'm on Windows).

          However, my code doesn't seems to work. I mean, there are no errors, bu the file is not downloaded and the FTP server doesn't receive any notifications.

          I spent my all day searching for a good example, but all I could get was this code. I also know I need to do something like this after:

              m_file.setFileName("file_1.png");
              m_file.open(QIODevice::WriteOnly | QIODevice::Append);
              m_file.write(myNetworkReply->readAll());
          

          But it doesn't change anything. No files created. Seems like the myNetworkReply var is empty.

          raven-worxR 1 Reply Last reply
          0
          • C CLBSII

            @raven-worx
            To be honest, my FTP server is running on a distant computer using this Python Library, so I'm not sure for the type.

            Well it seems you was right, I successfully installed the OpenSSL lib following your link and the error disappeared. Thanks for helping (and yes I'm on Windows).

            However, my code doesn't seems to work. I mean, there are no errors, bu the file is not downloaded and the FTP server doesn't receive any notifications.

            I spent my all day searching for a good example, but all I could get was this code. I also know I need to do something like this after:

                m_file.setFileName("file_1.png");
                m_file.open(QIODevice::WriteOnly | QIODevice::Append);
                m_file.write(myNetworkReply->readAll());
            

            But it doesn't change anything. No files created. Seems like the myNetworkReply var is empty.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #4

            @CLBSII
            when exactly do you execute this code?

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • C Offline
              C Offline
              CLBSII
              wrote on last edited by CLBSII
              #5

              @raven-worx
              During the initialization of my application. I call function that doing all those things:

              void MyApp::DownloadFtp()
              {
                 myNetworkManager = new QNetworkAccessManager(this);
                 QUrl url("ftp://Vprint_FTP:1234@192.168.1.62:2121/file_1.png");
                 qDebug()<<url;
                 myNetworkRequest.setUrl(url);
                 myNetworkReply = myNetworkManager->get(myNetworkRequest);
              
                 m_file.setFileName("file_1.png");
                 m_file.open(QIODevice::WriteOnly | QIODevice::Append);
                 m_file.write(myNetworkReply->readAll());
              }
              

              I don't know if it answer to your question ?
              One thing that bother me is that the qDebug line returns me :

              QUrl("sftp://Vprint_FTP@192.168.1.62:2121/1.png")
              

              It is the same line that I set, without the password. Is it normal ?

              raven-worxR 1 Reply Last reply
              0
              • C CLBSII

                @raven-worx
                During the initialization of my application. I call function that doing all those things:

                void MyApp::DownloadFtp()
                {
                   myNetworkManager = new QNetworkAccessManager(this);
                   QUrl url("ftp://Vprint_FTP:1234@192.168.1.62:2121/file_1.png");
                   qDebug()<<url;
                   myNetworkRequest.setUrl(url);
                   myNetworkReply = myNetworkManager->get(myNetworkRequest);
                
                   m_file.setFileName("file_1.png");
                   m_file.open(QIODevice::WriteOnly | QIODevice::Append);
                   m_file.write(myNetworkReply->readAll());
                }
                

                I don't know if it answer to your question ?
                One thing that bother me is that the qDebug line returns me :

                QUrl("sftp://Vprint_FTP@192.168.1.62:2121/1.png")
                

                It is the same line that I set, without the password. Is it normal ?

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by raven-worx
                #6

                @CLBSII
                this way the request probably wasnt event sent yet.
                you must connect to the finished signal of the reply and then read the data (and error checking of course)

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                1
                • C Offline
                  C Offline
                  CLBSII
                  wrote on last edited by
                  #7

                  @raven-worx
                  I'm not sure to understand. Do you mean I have to add some temporisation at some point ?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    Hi and welcome to devnet,

                    No, QNAM is an asynchronous class, you need to use signal and slots to implement your data processing once the answer fully arrived.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      CLBSII
                      wrote on last edited by
                      #9

                      Thanks for your time.

                      I found this example. Is it relevant with what you explained to me ?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #10

                        Yes, it's one way to implement it.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        1

                        • Login

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