Made a GET request to the site in a separate thread. But the shape for a few seconds is framed And it is completely incomprehensible why the request takes so long. A simple get request for c # can take 2–3 seconds. Immediately almost 10 seconds goes to the same request. What am I doing wrong?

link to github https://github.com/Radzhab/QTparser

#ifndef THREAD_H #define THREAD_H #include <QThread> #include <QTextEdit> #include <httphelper.h> class Worker : public QObject { Q_OBJECT QThread workerThread; HttpHelper *helper; public slots: void doWork(const QString &result) { emit resultReady(helper->GetHtml()); } signals: void resultReady(const QString &result); }; class Controller : public QObject { Q_OBJECT QThread workerThread; QTextEdit *textDesk; public: Controller(QTextEdit *txt): textDesk(txt) { Worker *worker = new Worker; worker->moveToThread(&workerThread); connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater())); connect(this, SIGNAL(operate(QString)), worker, SLOT(doWork(QString))); connect(worker, SIGNAL(resultReady(QString)), this, SLOT(handleResults(QString))); workerThread.start(); } ~Controller() { workerThread.quit(); workerThread.wait(); } public slots: void handleResults(const QString &str) { textDesk->append(str); } signals: void operate(const QString &); }; #endif // THREAD_H 
  • If you use QNetworkAccessManager to send requests, then you do not need to send them in a separate stream, because the manager himself creates threads as needed and with a maximum number of up to six. - alexis031182 pm

1 answer 1

Start wireshark and watch the bytes run. Surely the point is in the DNS request, so try to access the site directly by IP .

  • I do not think that Trouble in Ip, dns and so on. Why does everything in any other PL work quickly, and then he thinks for so long? - Radzhab
  • @Radzhab "other" YAP can use, for example, system-wide DNS cache. - gbg
  • It seems to have solved the problem by replacing QtextEdit with QPlaintTextEdit. - Radzhab
  • But for a fraction of a second a small frieze occurs - Rajab
  • @Radzhab and how can this be explained? - gbg