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. http request - resend after TCP failure
Qt 6.11 is out! See what's new in the release blog

http request - resend after TCP failure

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 534 Views 1 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
    Damian7546
    wrote on last edited by
    #1

    Hi,

    I send many http request from my app... Could any of you give me some pointers how save request which one are not send.... and try resend when TCP will go back to work ?
    Whether there is a any functionality to realize my problem in qt in simple way ? or I should save request (to file or QQueue<QByteArray> ?) when 404 erorr recive ?
    I would be really grateful for any ideas...

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

      Hi,

      That's up to you. From the looks of it, you seem to need to build a queue of requests or at least their components. Then when a request should be processed, extract that component, create and send the request and then keep a hash with the component associated to the reply object. If there's a failure, put the component back in the queue otherwise, clean things up.

      Note that you must also consider the number of failures and maybe stop at some point.

      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
      1
      • D Offline
        D Offline
        Damian7546
        wrote on last edited by
        #3

        @SGaist Any example how save QQueue to Qfile, and read QQueue from Qfile ? I need save not processed request , in the event of a device restart...

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

          First define how you are going to save your data. Will it be only text ? Will it contain binary data ? If the latter, why ?

          You can then implement QDataStream operators for your structure. The rest is handle automatically.

          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
          • D Offline
            D Offline
            Damian7546
            wrote on last edited by
            #5

            @SGaist said in http request - resend after TCP failure:

            First define how you are going to save your data. Will it be only text ? Will it contain binary data ? If the latter, why ?
            You can then implement QDataStream operators for your structure. The rest is handle automatically.

            I thinking saving my not processed request to text file, on example like below:

                QByteArray test1 =  "http://localhost:1234/v1/test";
                QByteArray test2 =  "http://localhost:1234/v1/test/testDevices";
                QByteArray test3 =  "http://localhost:1234/info";
            
                QQueue<QByteArray> queue;
                queue.enqueue(test1);
                queue.enqueue(test2);
                queue.enqueue(test3);
            
                QFile file("C:\\Test\\test.txt");
            
                if(!file.open(QFile::WriteOnly | QFile::Text)){
                    return;
                }
            
                QTextStream out(&file);
                while (!queue.isEmpty()) {
                    out << queue.dequeue();
                 }
            
                file.flush();
                file.close();
            

            is any better way ?

            JonBJ 1 Reply Last reply
            0
            • D Damian7546

              @SGaist said in http request - resend after TCP failure:

              First define how you are going to save your data. Will it be only text ? Will it contain binary data ? If the latter, why ?
              You can then implement QDataStream operators for your structure. The rest is handle automatically.

              I thinking saving my not processed request to text file, on example like below:

                  QByteArray test1 =  "http://localhost:1234/v1/test";
                  QByteArray test2 =  "http://localhost:1234/v1/test/testDevices";
                  QByteArray test3 =  "http://localhost:1234/info";
              
                  QQueue<QByteArray> queue;
                  queue.enqueue(test1);
                  queue.enqueue(test2);
                  queue.enqueue(test3);
              
                  QFile file("C:\\Test\\test.txt");
              
                  if(!file.open(QFile::WriteOnly | QFile::Text)){
                      return;
                  }
              
                  QTextStream out(&file);
                  while (!queue.isEmpty()) {
                      out << queue.dequeue();
                   }
              
                  file.flush();
                  file.close();
              

              is any better way ?

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by JonB
              #6

              @Damian7546
              Unless (a) you really intend to restart failed http requests on restarting your application at a later time, which seems odd to me, or (b) you have a large number of requests with large data content , why would you want to save to external storage, why not just keep the queue in session memory?

              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