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. QNetworkAcessManager | QThread::start: Failed to create thread

QNetworkAcessManager | QThread::start: Failed to create thread

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 4.0k Views
  • 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.
  • LodiCodeL Offline
    LodiCodeL Offline
    LodiCode
    wrote on last edited by LodiCode
    #1

    Hello guys, i am having a a problem when i get content of json files from one page, i receive this error QThread::start: Failed to create thread (Código de acesso inválido.)

    how to solve this?

    my request codes:

    void Parser::steamRequest()
    {
        QNetworkAccessManager * nan = new QNetworkAccessManager(this);
    
        ui->editGamesLogs->clear();
        QString key = ui->edit_key->text();
    
        league_id = 0;
    
        if(!vectorLeagues_id.isEmpty()){
            league_id = vectorLeagues_id[0];
            vectorLeagues_id.pop_front();
        }
        qDebug() << "FROM STEAM REQUEST LEAGUE ID: " << league_id << " Vector size" << vectorLeagues_id.size();
    
        if(league_id >= 1){
            QString urlSteam = "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key="+key+"&league_id="+QString::number(league_id,'.',0)+"";
            QUrl url(urlSteam);
    
            qDebug() << url.url() << urlSteam;
            connect(nan,SIGNAL(finished(QNetworkReply*)),this,SLOT(steamParser(QNetworkReply*)));
            nan->get(QNetworkRequest(url));
        }
    }
    
    void Parser::trackDotaRequest()
    {
    
        QNetworkAccessManager * nan1 = new QNetworkAccessManager(this);
    
        direPlayers.clear();
        radiantPlayers.clear();
        actionsRecord.clear();
        infosGeral.clear();
    
        match_id = 0;
    
        query = Connection::getQueryInstance();
    
        query.prepare("SELECT match_id FROM partida WHERE isTracked=0 and league_id=:league_id");
        query.bindValue(":league_id", league_id);
        query.exec();
        if(!query.next()){
            steamRequest();
        }else{
            match_id = query.value(0).toDouble();
        }
        Connection::getInstance(false);
    
        if(match_id >= 1){
            QString urlSteam;
            urlSteam = "http://www.trackdota.com/data/game/"+QString::number(match_id,'.',0)+"/live.json";
            QUrl url(urlSteam);
    
            ui->editGamesLogs->append("TrackDota Match ID" +QString::number(match_id,'.',0)+" está sendo carregado!");
            connect(nan1,SIGNAL(finished(QNetworkReply*)),this,SLOT(gameParser(QNetworkReply*)));
            
            nan1->get(QNetworkRequest(url));
        }
    }
    
    
    

    Let's code?

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

      Hi,

      Why are you creating one QNetworkAccessManager per query ? Use only one as class member and then avoid creating so many QNAM. The base class can handle multiple calls up to 6 in parallels and then it cues them.

      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
      • LodiCodeL Offline
        LodiCodeL Offline
        LodiCode
        wrote on last edited by
        #3

        i try do it with using only one QNAM but don't work, i still getting the same error, after more or less 100 acess

        Let's code?

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

          How fast are you creating the request ?
          What is that parser class ?

          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
          • LodiCodeL Offline
            LodiCodeL Offline
            LodiCode
            wrote on last edited by SGaist
            #5

            i remake all the project, see this code

            https://codepaste.net/ptr8qf

            my function to call this code

            
            void Parser::getSteamInformations()
            {
                if(contador == 0){
            
                    query = Connection::getQueryInstance();
                    vectorLeagues.clear();
                    if(query.exec("SELECT league_id FROM leagues_id")){
                        while(query.next()){
                            if(query.value(0).toDouble() > 0)
                                vectorLeagues.push_back(query.value(0).toDouble());
                        }
                    } else
                        qDebug() << query.lastError().text();
                    contador++;
                    Connection::getInstance(false);
                }
                if(vectorLeagues.size() > 0){
                    double value = vectorLeagues[0];
                    vectorLeagues.pop_front();
                    qDebug() << "GetSteamInformations iniciara " << value;
                    steamSlots->steamRequest("XXXXXXXXXXXXXXXXXXXXXXX", value);
                }
            }
            

            but when i try to get my list of 340 leagues, it stop and no go forward

            i need delete nam in every call? how to clear the nam, from the next requisition after my emit?

            [edit: removed ID SGaist]

            Let's code?

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

              It's surprising your code doesn't crash. You are making your nam variable a null pointer just before using it. Your replies are likely not getting deleted since you connect the finished signal while the reply already finished. You are also connecting the QNetworkAccessManager signals several times.

              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
              2
              • LodiCodeL Offline
                LodiCodeL Offline
                LodiCode
                wrote on last edited by SGaist
                #7

                I try put it in practice, but still don't work maybe i am made another mistake, i define nam and the connection in constructor, the first url is parsed sucefull, but the second stop and not go forward...

                steam::steam()
                {
                    max_match_id = 0;
                    min_match_id = 99999999999;
                
                    nam = new QNetworkAccessManager();
                    connect(nam,SIGNAL(finished(QNetworkReply*)),this,SLOT(steamParser(QNetworkReply*)));
                }
                
                LOGS:
                Obtendo informações do League :8
                Inclusão no banco de dados concluida! Adicionado 0 registros no banco de dados
                Obtendo informações do League :27 <-- stop here
                
                qDebug() LOGS
                "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&league_id=8" 
                "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&league_id=8&start_at_match_id=29378911"
                "Inclusão no banco de dados concluida! Adicionado 0 registros no banco de dados"
                343
                "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/v1/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&league_id=27" 
                

                Thanks alot for u time bro!

                [edit: Removed key SGaist]

                Let's code?

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

                  Will you please stop posting your steam key ?

                  That said, are you sure you're not getting throttled ?

                  You should also connect the error signals to see what is happening.

                  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