Why am I getting many “RemoteHostClosedError” sending a POST over HTTP?
I am trying to interact with a virtual reality software, NeuroVR. This software has a HTTP server and the user can send data through it. The server can be accessed by the localhost:8888. If access over a browser, there is a form to submit data. The type of data is a connector name and a connector value. So, I created a Qt5.5 console program to send data for the NeuroVR.
My problem: I am sending data each 4 seconds (more or less) and I am getting many "RemoteHostClosedError" as reply. In some cases I had sucess with an "HttpStatusCodeAttribute" equal 200, but the rate of success sometimes is less than 50%.
I thought that the problem was the server. So I made tests over the browser accessing the localhost:8888 sending data each 1(max of 2) secs. The server accepted all, it was perfect.
My program is based on this tutorial: Sending a HTTP request using Qt 5 framework
My QNetworkAccessManager and QNetworkRequest are attributes of the class. They are allocated at the constructor.
this->request = new QNetworkRequest(QUrl(this->nvrhost));
this->manager = new QNetworkAccessManager(this);
this->evLoop = new QEventLoop(this);
This method sends the request to the server:
void BciSocket::sendToNvr(QString data, QString connector)
My question: Why this is happening and how to can I avoid it? How to can I improve it?
Thanks for your attention!
Why are you creating your request on the heap rather than stack ?
Also, you never delete the request so you might be covering one with another and you have a memory leak.