Tuesday, 3 September 2019

Cordova jQuery AJAX call timing out after 30 seconds regardless of timeout setting

I'm trying to execute the following function on Android to sync with an IoT device I'm making:

function NewDeviceFetchDeviceID(){
    strURL = "https://192.168.x.x/.....";

    return $.ajax({
        url: strURL,
        type: 'GET',
        timeout: 90000
    });
}

The device takes some time to churn a response to the request (about 45-50 seconds) so I need the timeout to be slightly longer than 30s. The timeout seems to work on iOS - if I set it to 5 seconds it will do so, if I set it for 90 it will wait the whole time. For Android, it seems that this argument is ignored.

I tried adding the following into config.xml under <platform name="android"> with no luck:

<preference name="LoadUrlTimeoutValue" value="90000"/>

How can I properly increase the timeout argument for AJAX requests in a Cordova Android app?



from Cordova jQuery AJAX call timing out after 30 seconds regardless of timeout setting

No comments:

Post a Comment