admin管理员组文章数量:1565292
浏览器的默认值是5分钟
相关代码地址如下:https://source.chromium/chromium/chromium/src/+/main:net/socket/client_socket_pool;l=25
测试代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<button id="queryBtn">query</button>
<time id="time"></time>
<script>
const ajax = (url = '/api/timeout') => {
const xhr = new XMLHttpRequest();
//设置xhr请求的超时时间
xhr.timeout = 60 * 5 * 1000;
xhr.responseType = "text";
xhr.open('GET', url, true);
xhr.onload = function(e) {
if(this.status == 200 || this.status == 304){
console.log('请求完毕')
if(loopId) {
clearInterval(loopId)
}
}
console.log(e)
}
xhr.send()
}
const queryBtn = document.querySelector('#queryBtn')
const time = document.querySelector('#time')
loopId = null
queryBtn.addEventListener('click', (event) => {
ajax()
const startTime = new Date()
loopId = setInterval(() => {
const s = parseInt((new Date() - startTime) / 1000)
time.innerHTML = s + ' s'
}, 500)
})
</script>
</body>
</html>
修改 Chrome 的超时设置
谷歌浏览器不会让用户更改 Chrome 的超时设置。
下面操作未经过测试,感兴趣的可以试试看
通过编辑注册表来处理这个问题。我认为注册表不仅会影响 IE,还会影响 Windows 10 中的 Chrome。我尝试延长超时时间。然后我可以延长它,在我的情况下,最大超时时间约为 7 小时。
单击“开始”或按Win-R以获取“运行”框,键入regedit
,然后单击“确定”。
在注册表中找到并单击以下项:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\InternetSettings
在编辑菜单上,指向新建,然后单击 DWORD 值。
键入KeepAliveTimeout
,然后按 Enter。
在编辑菜单上,单击修改。
键入适当的超时值(以毫秒为单位),然后单击“确定”。例如,要将超时值设置为两分钟,请键入120000
。
创建另一个 DWORD 值ServerInfoTimeout
并将其设置为相同的值。
重启机器。
版权声明:本文标题:chrome浏览器的默认超时时间 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1726732720a1082424.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论