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. XMLHttpRequest : doesn't work anymore after a reconnection

XMLHttpRequest : doesn't work anymore after a reconnection

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 1.8k 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.
  • GeoffroyG Offline
    GeoffroyG Offline
    Geoffroy
    wrote on last edited by
    #1

    Hi everybody,

    Like mentionned in the title, I can't reach anymore my internet connection after a deconnection / reconnection

    I think that is a big regression since Qt 5.5.1 because I don't have this problem with Qt 5.5.0

    Here is a minimal code to reproduce the issue :

    Window {

    visible: true
    
    Button {
    
        text: "Test"
    
        onClicked: {
    
            req = new XMLHttpRequest()
            req.onreadystatechange = function (event) {
                if (req.readyState === XMLHttpRequest.DONE) {
                    console.log("Make request : status = " + req.status)
                    console.log(req.responseText.toString())
                }
            }
    
            req.open("GET", "http://www.google.fr", true)
            req.send()
        }
    }
    

    }

    Steps to reproduce :

    1. Execute the code above
    2. Click on the test button : you should see data from google
    3. Turn off your wifi adapter
    4. Click on test: nothing appears : status is equal to 0
    5. Turn on your wifi adapter
    6. Click on test several times: you can't reach data anymore. Status is always equals to 0
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should add which OS you're running on

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

        Hi, Thanks.

        I've found this problem on Mac OSX, Ios & Android (with Qt 5.5.1 release version for MacOSX)

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

          Then I'd recommend checking the bug report system to see if it's something known. If not please consider opening a new report providing a minimal compilable example (with the qml you have here) to reproduce the behavior.

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

            Hi,

            I suggest to print the readyState in the change state handler

                    req.onreadystatechange = function (event) {
                        console.log("readyState: " + req.readyState);
                        if (req.readyState === XMLHttpRequest.DONE) {
                            console.log("Make request : status = " + req.status)
                            console.log(req.responseText.toString())
                        }
                    }
            

            in that case you can see what happens in your connection

            Once your problem is solved don't forget to:

            • Mark the thread as SOLVED using the Topic Tool menu
            • Vote up the answer(s) that helped you to solve the issue

            You can embed images using (http://imgur.com/) or (http://postimage.org/)

            1 Reply Last reply
            0
            • GeoffroyG Offline
              GeoffroyG Offline
              Geoffroy
              wrote on last edited by Geoffroy
              #6

              Hi,

              I will detail a little bit more what happens.

              Reminder about ready state code :
              0: request not initialized
              1: server connection established
              2: request received
              3: processing request
              4: request finished and response is ready

              Here is my log :

              [Wifi is enabled, I make a first request]

              qml: readyState: 1
              qml: readyState: 2
              qml: readyState: 3
              qml: readyState: 3
              qml: readyState: 3
              qml: readyState: 4
              qml: request status 200 => everything is OK

              [I switch off my wifi adapter, and make a request again]

              qml: readyState: 1 => status 1 = server connection established ( strange isnt' it ? )

              [after 10s, I switch on my wifi adapter]

              qml: readyState: 2
              qml: readyState: 3
              qml: readyState: 3
              qml: readyState: 3
              qml: readyState: 4
              qml: request status 200 => ok, my last request was completed normally

              [make other requests, several time ]

              qml: readyState: 1
              qml: readyState: 4
              qml: request status 0

              ...

              qml: readyState: 1
              qml: readyState: 4
              qml: request status 0

              I hope this will help you ..
              I'm currently develop a mobile application where this kind of scenario can often appear ..

              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