2

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

I read a lot of topics here on the StackOverflow, but these two were more useful: Topic 1 Topic 2

My QNetworkAccessManager and QNetworkRequest are attributes of the class. They are allocated at the constructor.

this->request = new QNetworkRequest(QUrl(this->nvrhost));
request->setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
this->manager = new QNetworkAccessManager(this);
connect(this->manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyNVR(QNetworkReply*)));
this->evLoop = new QEventLoop(this);
connect(this->manager,SIGNAL(finished(QNetworkReply*)),this->evLoop,SLOT(quit()));

This method sends the request to the server:

void BciSocket::sendToNvr(QString data, QString connector)
{
    QUrlQuery query;
    query.addQueryItem("connectorID",connector);
    query.addQueryItem("connectorValue",data); 
    this->manager->post((*request),query.toString(QUrl::FullyEncoded).toUtf8());
    this->evLoop->exec();
}

My question: Why this is happening and how to can I avoid it? How to can I improve it?

Community
  • 1
  • 1
ANSantana
  • 33
  • 5

0 Answers0