Hi all

My app uses XMLHttpRequests within Javascript to connect to a web service.

The problem we are having is that when the handset loses connectivity and then finds it again, we are unable to make any more successful requests.

Also, we use the Qt Mobility Map object. After losing then regaining connectivity, the Map can no longer display any tiles either.

Here's an example to illustrate the problem

main.qml
Code:
import QtQuick 1.0
import "NetTest.js" as JS

Rectangle {
    id: screen
    width: 360
    height: 360
    Column {
        anchors.centerIn: parent
        Text {
            text: "Callbacks: 0"
            id: callbacks
        }

        Text {
            text: "Errors: 0"
            id: errors
        }
    }

    Timer {
        running: true
        repeat: true
        interval: 10000
        onTriggered: {
            console.log("Net test request");
            JS.request(screen.callback, screen.errback)
        }
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            Qt.quit();
        }
    }

    function callback() {
        JS.numCallbacks++
        callbacks.text = "Callbacks: " + JS.numCallbacks
    }

    function errback() {
        JS.numErrors++
        errors.text = "Errors: " + JS.numErrors
    }
}
NetTest.js
Code:
var numCallbacks = 0
var numErrors = 0

function request(callback, errback) {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "http://www.google.co.uk", true);
    xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    xhr.setRequestHeader("Data-Type", "json");
    xhr.onreadystatechange = function () {
        console.log("Ready state: " + xhr.readyState)
        console.log("Resp text: " + xhr.responseText)
        console.log("Status: " + xhr.status)
        if (xhr.readyState == xhr.DONE) {
            try {
                if (xhr.status != 200 && typeof errback !== 'undefined') {
                    errback();
                } else if (typeof callback !== 'undefined') {
                    callback();
                }
            } catch (err) {
                console.log("GetTraffic err: " + err);
                if (typeof errback !== 'undefined') {
                    errback();
                }
            }
        }
    }

    xhr.send();
}
1) run app
2) observe Callbacks incrementing every 10 seconds
3) Press power button, select Offline mode
4) observe Errors incrementing every 10 seconds
5) Press power button, select General mode

Actual: Errors continues to increment every 10 seconds
Expected: Callbacks increments every 10 seconds

How can we make the app reconnect again?

The problem doesn't happen on the Qt simulator, but it does on the N8.

Thanks