Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error on my application: (process:9105): GLib-ERROR **: Creating pipes for GWakeup: Too many open files
Forum Updated to NodeBB v4.3 + New Features

Error on my application: (process:9105): GLib-ERROR **: Creating pipes for GWakeup: Too many open files

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 6.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dcbasso
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dcbasso
      wrote on last edited by
      #2

      I remove the line:
      ´´´
      reply = manager->post(request, data.toUtf8());
      ´´´
      And them stop to crash the app...

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dcbasso
        wrote on last edited by dcbasso
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • D Offline
          D Offline
          dcbasso
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            D 1 Reply Last reply
            0
            • D Offline
              D Offline
              dcbasso
              wrote on last edited by
              #6

              I try to do that I got another errors.
              I will check this again, I try to clear and remove the reference and etc... But I don't found anything about it.

              I will try more!

              Thanks

              1 Reply Last reply
              0
              • SGaistS SGaist

                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.

                D Offline
                D Offline
                dcbasso
                wrote on last edited by dcbasso
                #7

                @SGaist

                Well I use 3 QNetworkAccessManager and 1 QTcpSocket:

                1. Check Internet Connection (With google), checked every second;
                2. Check Server Connection, checked every second too;
                3. 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.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  dcbasso
                  wrote on last edited by
                  #8

                  Yeap... The app take longerrrrr to crash, but I got same error...

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    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)

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    D 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      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)

                      D Offline
                      D Offline
                      dcbasso
                      wrote on last edited by dcbasso
                      #10

                      @SGaist I can instantiate on MainWindow, at start up and pass the pointer to other classes, that's correct?
                      And I can make any connection withs signals to handle each request that I make?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        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.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved