测试发现,使用 XMLHttpRequest 超过一百多次后无法发出数据:通过抓包发现并没有发出任何数据,即便是解析 DNS 这一步也没有。
下面是请求的代码:
let requestCount = 0;
function get(url, onNext, onError) {
let xhr = new XMLHttpRequest();
let id = requestCount++;
xhr.timeout = 10000;
xhr.onload = () => {
if (xhr.status >= 200 && xhr.status < 300) {
onNext(xhr.response);
} else {
onError(new Error(`request[${id}] url: ${url} failed, ${xhr.statusText}`));
}
};
xhr.onerror = () => {
onError(new Error(`request[${id}] url: ${url} failed, network error`));
};
xhr.ontimeout = () => {
onError(new Error(`request[${id}] url: ${url} failed, time out`));
};
cc.log(`start request: ${id}`);
xhr.open('GET', url, true);
xhr.send();
return () => xhr.abort();
}
希望引擎组的人帮忙看看,谢谢
HttpIssue.zip (165.6 KB)
