Unsolved QNetworkAccessManager doesn't post request in case of large file
-
@Robert-Winke Are you sure the QFile instance is create in same thread as
_pReply
?
You could change the code as follow:auto currentFile = _file.release(); _pReply = _netMan.post(postFileRequest, currentFile); ... // capture QFile pointer in lambda and delete it there QObject::connect(_pReply, &QNetworkReply::finished, [this, currentFile ](){ // also catch FP here auto error = this->_pReply->error(); currentFile->delateLater(); ... });
-
@KroMignon said in QNetworkAccessManager doesn't post request in case of large file:
e threa
yes, they are in the same thread also it already opens the file just before the post request so it exists.
I made your recommended change, it does seem more elegant but my problem persists:( -
Have you tried to upload using other tools?
Maybe your server has size limitation for uploads. -
@Robert-Winke I read again you first post, you write error 2 which is
QNetworkReply::RemoteHostClosedError
.This means that the server closed the socket. So perhaps the problem is not on this software but on the server side.
Are there logs you can check or do you have tried to look tcp traffic with a network sniffer like WireShark? -
@KroMignon That is a good guess but I forgot to mention that I have a python script which makes this post request with the large file without a problem and the server receives the file so it can't be a server side problem..
I am using wireshark to monitor the traffic and in case of large file I don't see the post request (no packets leave my computer) but with the small file I see it and it works -
@Robert-Winke It look like you hurting same issue as this one ==> https://www.kdab.com/there-and-back-again/
-
@Bonnie Yes I have a working python script so it's not a server side problem but it's a good guess. I edited the original post
-
@JonB I think it should be fine as a local variable but just in case I made it a member var but it didn't help:(
-
Hi,
Would it be possible to provide a minimal example application and server that shows that issue ?
-
@KroMignon I tried with the patch for that issue but it didn't help. That description is mostly just about latency issue. :(
-
@Robert-Winke
If you hope for an answer here, I suggest you have a go at @SGaist's request, we need some minimal sample app to reproduce. -
@SGaist yes, I created a sandbox project for this with a working web server in python. There is a readme with instructions how to build and test it. I tried to attach the file here but I dont have enough privileges so here is a google drive link:
https://drive.google.com/drive/folders/1lxPun_p_crKlui5KU8Q1qKBp0ue7vvok?usp=sharing
-
@SGaist ps the error with this web server is not the same. This time I can see the post request from wireshark but the client receives Error code: 99 Unknown error. The progress still doesn't go up to 50 (100%) but it does with the small.txt
-
Your sample Python server does not handle post requests properly and kills the connection early.
Once that fixed, big files are properly uploaded.
Now the question is:
auto prog = sent*100/(2*static_cast<double>(total));
What does that 2 do in there ? Mathematically, you can't reach 100% with that equation unless you send twice the number of bytes.
-
@SGaist That 2 doesn't matter, I'm not expecting it to go to 100 just 50 I just forgot to remove it for this sandbox project.
I'll look into the python server but that's not actually the server I used for testing. The one I used is proven to be working with another client but I cannot attach that. -
@SGaist okay by changing the server it does seem to work but now I'm completely lost because the server I used before works too just not with my client...
-
@Robert-Winke said in QNetworkAccessManager doesn't post request in case of large file:
okay by changing the server it does seem to work
I am just curious to know what to you have changed in server code. At first look, I can not see what wrong with it.
Can you please show me the changes? -
@KroMignon I uploaded the new server code in the same zip