XMLHttpRequest : doesn't work anymore after a reconnection
-
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 :
- Execute the code above
- Click on the test button : you should see data from google
- Turn off your wifi adapter
- Click on test: nothing appears : status is equal to 0
- Turn on your wifi adapter
- Click on test several times: you can't reach data anymore. Status is always equals to 0
-
Hi and welcome to devnet,
You should add which OS you're running on
-
Hi, Thanks.
I've found this problem on Mac OSX, Ios & Android (with Qt 5.5.1 release version for MacOSX)
-
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.
-
Hi,
I suggest to print the
readyState
in the change state handlerreq.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
-
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 readyHere 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 0I hope this will help you ..
I'm currently develop a mobile application where this kind of scenario can often appear ..