Error on my application: (process:9105): GLib-ERROR **: Creating pipes for GWakeup: Too many open files
-
Well I think it's about threads, the limitation os System!
But I can't find the problem!I think the problem is here:
#include "restservices.h" RestServices::RestServices(QObject *parent) : QObject(parent) { } void RestServices::send(QString data) { QStringList lista= data.split("$", QString::SkipEmptyParts); for (int i=0; i<lista.size(); i++) { qDebug() << "$" << lista.at(i); sendRequest("$" + lista.at(i)); } } void RestServices::sendRequest(QString data) { QNetworkAccessManager *manager = new QNetworkAccessManager(this); QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), SLOT(slotRequestFinished(QNetworkReply *))); QNetworkRequest request; request.setUrl(QUrl("http://192.168.25.105:9763/CronoboxServer/rest/data/dados")); request.setHeader(QNetworkRequest::ContentTypeHeader, "text/plain"); QNetworkReply *reply = 0; reply = manager->post(request, data.toUtf8()); } void RestServices::slotRequestFinished(QNetworkReply *reply) { if (reply->error() > 0) { qDebug() << reply->errorString(); } else { qDebug() << "Retornou: " << reply->readAll(); } }
So when I call to many times the method "send" I got error " GLib-ERROR **: Creating pipes for GWakeup: Too many open files".
I think that is about Threads, but I can't find a Way to avoid this problem!
Can anyone help me? -
I see this at log output:
Erro: "Out of resources"
´´´
void RestServices::slotRequestFinished(QNetworkReply *reply)
{
if (reply->error() > 0) {
qDebug() << "Erro: " << reply->errorString();
} else {
qDebug() << "Retornou: " << reply->readAll();
}
}
´´´Still getting erros.
Anyone? -
Hi,
You are creating a new QNetworkAccessManager each time you call sendRequest and never delete it, the same goes for the QNetworkReply.
You should have only one QNetworkAccessManager for your application and take care of cleaning up the QNetworkReply.
-
Well I use 3 QNetworkAccessManager and 1 QTcpSocket:
- Check Internet Connection (With google), checked every second;
- Check Server Connection, checked every second too;
- The main: Send data received from QTcpSocket (I read data from another App thru TCP Socket).
So, appears to be an error on item 3. After start send data do server I get the crash, so...
- I change all QNetworkAccessManager to use each one single Instance (can I call Instance in C/C++) and this change:
void RestServices::slotRequestFinished(QNetworkReply *reply) { reply->close(); delete myManager; }
So each "send" create a new myManager and after send DELETE it...
Appears more stable (for longer) at this moment. I will need test more. -
You can use a single QNetworkAccessManager for your application. It will handle parallel connections for you (up to six at the same time and it will queue other requests made IIRC)
-
You can yes.
Since you are making a REST service interface. You should rather have an object that represent that service and have your widgets call functions on that object. That way you can modify the REST service if you want and only have one place in your code that you will need to modify.