QNetworkAccessManager long delay to emit finished signal



  • I use a QNAM to handle uploads using a ftp protocol. The whole process works but I have a strange behavior:

    this is my method :
    @void ftp::uploadFile(const QString &origin, const QString &destination)
    {
    QUrl url("ftp://"+host+""+destination);
    url.setUserName(user);
    url.setPassword(pwd);
    url.setPort(21);

    localFile = new QFile(origin, this);
    if (localFile->open(QIODevice::ReadOnly))
    {
         reply = nam->put(QNetworkRequest(url), localFile);
         QObject::connect(reply, SIGNAL(uploadProgress(qint64, qint64)), SLOT(transferProgress(qint64, qint64)));        
         QObject::connect(reply, SIGNAL(finished()), this, SLOT(transferFinished()));
    }
    else qDebug() << localFile->errorString();
    

    }@

    When I upload a file, the uploadProgress is emitted :

    @qDebug() << sent << "/" << total;@

    outputs the 0/x till the x/x . Then it takes a long time, maybe up to 20 seconds before the finished signal is emitted. Why this delay?

    I tried ignoring the finished signal and emit the signal myself when the progress is at sent==total but the file is corrupted at the other end. (It's not really corrupted, as I only send jpg, The resulting file is an upper-half only jpg. a big part is just grey.)

    I'd like to provide my users with a progress bar where 100% really means the process is finished. Uploading for 5 seconds, then staying for 20 seconds at 100% isn't really nice. What am I doing wrong?



  • I have the exact same problem except over http. I have found out that also the download progress signal takes this long time. And it is not because of my internet connection, bc it needs to download 60 bytes.



  • I have the exact same problem except over http. I have found out that also the download progress signal takes this long time. And it is not because of my internet connection, bc it needs to download 60 bytes.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.