这种情况一两个月前就开始发生了。我有一个节点脚本,它从以下位置获取:
https://raw.githubusercontent.com/glowbuzzer/gbr/master/package.json
这已经开始失败大约三分之一,但并非所有方法(所有方法都在同一台机器上运行)。
❌ Windows 版 Git 下的 curl
❌ Windows 中的 nodejs 脚本
❌ WSL 下 Ubuntu 中的 curl
❌ WSL 下的 Ubuntu 中的 nodejs
✅ PowerShell 中的 Invoke-WebRequest
✅ 在客户 Linux VM 中使用 curl
✅ 客户 Linux VM 中的 nodejs 脚本
我尝试过在家庭和工作网络上进行同样的操作。
我怀疑是 SSL 握手问题。如果 Invoke-WebRequest 在 PowerShell 中不起作用,我会假设这是一个损坏的 Windows 密钥库或类似的东西。请注意,Windows 版 Git 中的 curl 是使用schannel
(参见日志输出)进行编译的。
我已经在谷歌上搜索了很多次,但找不到有同样问题的人。我应该强调的是,这是间歇性- 每次请求都不会出错。
任何帮助都非常感谢。完整日志如下。
在 Windows 版 Git 下
$ curl --version
curl 8.1.2 (x86_64-w64-mingw32) libcurl/8.1.2 Schannel zlib/1.2.13 brotli/1.0.9 zstd/1.5.5 libidn2/2.3.4 libpsl/0.21.2 (+libidn2/2.3.3) libssh2/1.11.0
Release-Date: 2023-05-30
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL SSPI threadsafe UnixSockets zstd
$ curl https://raw.githubusercontent.com/glowbuzzer/gbr/master/package.json
curl: (35) Recv failure: Connection was reset
$ cat <<EOF > fetch.mjs
import https from "https";
console.log("making request")
const res=https.request("https://raw.githubusercontent.com/glowbuzzer/gbr/master/package.json", res => {
console.log("statusCode", res.statusCode);
res.on("data", d => {
process.stdout.write(d);
});
res.on("error", e => {
console.error(e);
});
res.on("end", () => {
console.log("No more data in response.");
});
});
res.end()
EOF
$ node fetch.mjs
making request
node:events:491
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (node:_http_client:502:9)
at TLSSocket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}
Node.js v18.16.0
在 WSL 下(Ubuntu)
$ curl https://raw.githubusercontent.com/glowbuzzer/gbr/master/package.json
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443
# same script as above in fetch.mjs
$ node fetch.mjs
making request
node:events:492
throw er; // Unhandled 'error' event
^
Error: Client network socket disconnected before secure TLS connection was established
at connResetException (node:internal/errors:720:14)
at TLSSocket.onConnectEnd (node:_tls_wrap:1605:19)
at TLSSocket.emit (node:events:526:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (node:_http_client:501:9)
at TLSSocket.emit (node:events:514:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ECONNRESET',
path: null,
host: 'raw.githubusercontent.com',
port: 443,
localAddress: undefined
}
电源外壳
> Invoke-WebRequest https://raw.githubusercontent.com/glowbuzzer/gbr/master/package.json
StatusCode : 200
StatusDescription : OK
答案1
禁用 Killer 网络服务似乎已经解决了这个问题。禁用网络适配器上的 ipv6 似乎也能解决问题,但我更喜欢禁用 Killer 网络服务。