Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Transfer timeout for GET requests is ignored, request gets canceled after 30s of data transfer

Transfer timeout for GET requests is ignored, request gets canceled after 30s of data transfer

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
8 Posts 3 Posters 1.3k 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.
  • A Offline
    A Offline
    Alexanderr
    wrote on last edited by
    #1

    I am making a GET requests using QNetworkRequest and QNetworkAccessManager::get(). It works for fast requests on small data sets. But if the request takes longer then 30 seconds to complete it gets canceled. There are no problems with the connection and in that time data is being transferred. Network connection is slow and there is a lot of data so 30 seconds is just not enough to complete the requests.

    I've tried setting QNetworkAccessManager::setTransferTimeout to a larger value but that has no effect. I've also tried setting it using QNetworkRequest::setTransferTimeout but that did not compile to webasm with an error that there is no such method.
    Is there a way to control transfer timeout for requests from webasm?

    Right now I am using Qt 5.15 and Emscripten 1.39.8 as recommended in documentation.

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

      Hi,

      Is it the actual time passed to do the transfert or already at connection ?

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

        The connection gets established almost instantly. 30 seconds is the actual time for data transfer. If I open the network tab in browsers developer console I see the request and I see that the actual data is constantly received. At exactly 30 seconds mark for this request it just stops.
        The actual data amount transferred during this time changes a bit depending on transfer speed.

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

          There's a connect timeout that you can set through QNetworkConfiguration but I currently don't remember whether it's also used for the rest of the operations.

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

            Isn't that a different thing? Connection timeout is time given to establish a connection (and is even stated so in documentation). After a connection gets established connection timeout should not have effect on the active data transfer.
            In my case connection gets established in around 100 milliseconds.

            QNetworkRequest::setTransferTimeout seams like what I looking for, but values set here don't have any effect on the actual request. In a browser shouldn't the expected behavior of setting this be equal to something like setting XMLHttpRequest.timeout for JavaScript request?

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

              Yes it should but I was just thinking about some workaround for your use case.

              As for your second question, possibly yes but that I do not know.

              Maybe @lorn-potter might know.

              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
              • lorn.potterL Offline
                lorn.potterL Offline
                lorn.potter
                wrote on last edited by
                #7

                Hi,

                https://bugreports.qt.io/browse/QTBUG-83867

                Both QNetworkAccessManager::setTransferTimeout and QNetworkRequest::setTransferTimeout currently depend on Qt's 'http' feature, which WebAssembly does not use due to incompatibilities with the backend code, and that we implement the backend using javascript's XMLHttpRequest API because we do not have real sockets available for the 'http' backend to be fully functional.

                That said, I do have a patch that adds support for setTransferTimeout, but requires breaking those functions out of the #if QT_CONFIG(http) defines. I just uploaded it here:

                https://codereview.qt-project.org/c/qt/qtbase/+/307407

                It currently uses QNetworkRequest::DefaultTransferTimeoutConstant

                Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
                Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

                1 Reply Last reply
                2
                • A Offline
                  A Offline
                  Alexanderr
                  wrote on last edited by
                  #8

                  Thanks for the update. When can we expect this merged?

                  Also why was QNetworkRequest::DefaultTransferTimeoutConstant used for default value? In the documentation https://doc.qt.io/qt-5/qnetworkrequest.html#setTransferTimeout if the function was never called the actual default value is stated to be 0 which is equal to no time limit. DefaultTransferTimeoutConstant is just used as default value if the function was called without any arguments.

                  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