连接失败了,帮忙看下
➜ corplink-rs-5.1-macos-arm64 ./corplink-rs config.json
thread 'main' panicked at src/main.rs:109:29:
called Result::unwrap() on an Err value: ReqwestError(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("jinglian.domain.com")), port: Some(10443), path: "/api/login/setting", query: Some("os=Android&os_version=2"), fragment: None }, source: hyper::Error(Connect, "unexpected eof while tunneling") })
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
报错信息是 "unexpected eof while tunneling" ,检查一下 jinglian.domain.com:10443/api/login/setting 是否能正常访问
可以正常访问的
➜corplink-rs-5.1-macos-arm64 curl -v https://jinglian.domain.com:10443/api/login/setting?os=Android&os_version=2
- Host jinglian.domain.com:10443 was resolved.
- IPv6: (none)
- IPv4: 218.2.102.70
- Trying 218.2.102.70:10443...
- Connected to jinglian.domain.com (218.2.102.70) port 10443
- ALPN: curl offers h2,http/1.1
- (304) (OUT), TLS handshake, Client hello (1):
- CAfile: /etc/ssl/cert.pem
- CApath: none
- (304) (IN), TLS handshake, Server hello (2):
- TLSv1.2 (IN), TLS handshake, Certificate (11):
- TLSv1.2 (IN), TLS handshake, Server key exchange (12):
- TLSv1.2 (IN), TLS handshake, Server finished (14):
- TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
- TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
- TLSv1.2 (OUT), TLS handshake, Finished (20):
- TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
- TLSv1.2 (IN), TLS handshake, Finished (20):
- SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 / [blank] / UNDEF
从代码来看,是连上服务器过后没有正常读到返回。如果是 api 不匹配,会报 http 相关的错误,这里直接报 EOF ,像是网络的问题。你排查一下你网络的问题吧
loop {
let n = conn.read(&mut buf[pos..]).await?;
if n == 0 {
return Err(tunnel_eof());
}
pos += n;
// ...
}
https://github.com/seanmonstar/reqwest/blob/cf69fd4bfe22855d576497eb94e9eb549e742475/src/connect.rs#L708-L714