1

Note: This issue was caused by my using HTTPS when the site only supported HTTP. Check this if you're having this issue!


I'm trying to make a small web crawler in Rust. When I try to send a GET request using the reqwest library, the program hangs.

My code that shows this problem:

extern crate reqwest;

use reqwest::Client;

fn main() {
    let client = Client::new();

    println!("Checkpoint 1!");
    println!("=> {:?}", client.get("https://eth0.me").send().unwrap().text());
    println!("Checkpoint 2!");
}

Running in the terminal:

$ cargo run
  Finished dev [unoptimized + debuginfo] targets in 0.0 secs
  Running `target/debug/crawler`
Checkpoint 1!

It seems the request times out, as later (1 minute, I think):

    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

In strace, it seems to hang on futex(0x7ff6b0e2105c, FUTEX_WAIT_PRIVATE, 0, {tv_sec=29, tv_nsec=999994794}. It also seems to have a missing ), which is revealed when ^C or timeout occurs. It equals -1 ETIMEDOUT (Connection timed out when it times out.

thatlittlegit
  • 69
  • 1
  • 8
  • 2
    Using `curl -vvvvvv "https://eth0.me"` or accessing the site in a web browser has the exact same problem. Requesting `http://` works. This has nothing to do with Reqwest or even Rust. Please explore more debugging avenues in the future. – Shepmaster Mar 31 '18 at 01:41
  • Sorry about that - I just picked the first plaintext URL I could think of, and figured it'd work with HTTPS. Sorry for spending your time on this; it works like a charm with HTTP. – thatlittlegit Mar 31 '18 at 01:51

0 Answers0