注意:此问题是由于我在网站仅支持HTTP时使用HTTPS引起的。如果你遇到这个问题,请检查一下!
我正在尝试在Rust中创建一个小型Web爬虫。当我尝试使用reqwest库发送GET请求时,程序会挂起。
我的代码显示了这个问题:
$ cargo run
Finished dev [unoptimized + debuginfo] targets in 0.0 secs
Running `target/debug/crawler`
Checkpoint 1!
在终端中运行:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Io(Custom { kind: WouldBlock, error: StringError("timed out") }), url: Some("https://eth0.me/") }', libcore/result.rs:945:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at libstd/sys_common/backtrace.rs:59
at libstd/panicking.rs:380
3: std::panicking::default_hook
at libstd/panicking.rs:396
4: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:576
5: std::panicking::begin_panic
at libstd/panicking.rs:537
6: std::panicking::begin_panic_fmt
at libstd/panicking.rs:521
7: rust_begin_unwind
at libstd/panicking.rs:497
8: core::panicking::panic_fmt
at libcore/panicking.rs:71
9: core::result::unwrap_failed
at /checkout/src/libcore/macros.rs:23
10: <core::result::Result<T, E>>::unwrap
at /checkout/src/libcore/result.rs:782
11: crawler::main
at src/main.rs:8
12: std::rt::lang_start::{{closure}}
at /checkout/src/libstd/rt.rs:74
13: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:479
14: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
15: std::rt::lang_start_internal
at libstd/panicking.rs:458
at libstd/panic.rs:358
at libstd/rt.rs:58
16: std::rt::lang_start
at /checkout/src/libstd/rt.rs:74
17: main
18: __libc_start_main
19: _start
似乎请求超时,如后(1分钟,我认为):
futex(0x7ff6b0e2105c, FUTEX_WAIT_PRIVATE, 0, {tv_sec=29, tv_nsec=999994794}
在strace中,它似乎挂在)
上。它似乎也缺少-1 ETIMEDOUT (Connection timed out
,当^ C或超时发生时会显示。它超时时等于{{1}}。