Skip to content

Timeout XMLHttpRequest not working in Android #26240

@navata

Description

@navata

Hi All,

I have use XMLHttpRequest for request to server. I have set timeout = 90000ms and my request about 14000ms. But It usually have error.

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = e => {
    if (xhr.readyState !== 4) {
        return;
    }

    if (xhr.status === 200) {
        console.log("success", xhr.responseText);
    } else {
        console.warn("error");
    }
};
xhr.open(
    "POST",
    "http://125.234.136.71/index.php?route=apiv4/post_timeout"
);
xhr.setRequestHeader("Content-type", "application/json; charset=utf-8");
xhr.timeout = 90000; // Set timeout to 90 seconds (90000 milliseconds)
xhr.ontimeout = function() {
    alert("Timed out!!!");
};
xhr.send();

My request is working on IOS and Postman, but it don't work on Android.
And more, I try set timeout = 0 (Infinite timer ) => it don't work -_-

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPlatform: AndroidAndroid applications.Ran CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.🌐NetworkingRelated to a networking API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions