"thread 'async-std/runtime' panicked" when running "echo-server" example
stnbu opened this issue · 1 comments
stnbu commented
Per the comments I run
cargo run --features="async-std-runtime" --example echo-server 127.0.0.1:123452
And I made two connection's using the "websocat" utility crate.
websocat ws://127.0.0.1:12345
Everything works as expected, I can send/receive from both clients, but at some point I see a panic in the server output.
This is at f5025ed / "0.17.2"
Here is my rustup show
output
Default host: x86_64-apple-darwin
rustup home: /Users/mburr/.rustup
installed toolchains
--------------------
stable-x86_64-apple-darwin (default)
nightly-x86_64-apple-darwin
1.52.1-x86_64-apple-darwin
1.60.0-x86_64-apple-darwin
installed targets for active toolchain
--------------------------------------
thumbv7m-none-eabi
wasm32-unknown-unknown
x86_64-apple-darwin
active toolchain
----------------
stable-x86_64-apple-darwin (default)
rustc 1.61.0 (fe5b13d68 2022-05-18)
Here is the ugly panic output on the terminal.
Compiling async-tungstenite v0.17.2 (/Users/mburr/git/async-tungstenite)
Finished dev [unoptimized + debuginfo] target(s) in 18.31s
Running `target/debug/examples/echo-server '127.0.0.1:12345'`
thread 'async-std/runtime' panicked at 'Failed to forward messages: Protocol(ResetWithoutClosingHandshake)', examples/echo-server.rs:53:10
stack backtrace:
0: rust_begin_unwind
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
2: core::result::unwrap_failed
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
3: core::result::Result<T,E>::expect
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1035:23
4: echo_server::accept_connection::{{closure}}
at ./examples/echo-server.rs:50:5
5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/future/mod.rs:91:19
6: <async_std::task::builder::SupportTaskLocals<F> as core::future::future::Future>::poll::{{closure}}
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.12.0/src/task/builder.rs:199:17
7: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::{{closure}}
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.12.0/src/task/task_locals_wrapper.rs:60:13
8: std::thread::local::LocalKey<T>::try_with
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/thread/local.rs:442:16
9: std::thread::local::LocalKey<T>::with
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/thread/local.rs:418:9
10: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.12.0/src/task/task_locals_wrapper.rs:55:9
11: <async_std::task::builder::SupportTaskLocals<F> as core::future::future::Future>::poll
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.12.0/src/task/builder.rs:197:13
12: async_executor::Executor::spawn::{{closure}}
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:144:19
13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/future/mod.rs:91:19
14: <core::pin::Pin<P> as core::future::future::Future>::poll
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/future/future.rs:124:9
15: async_task::raw::RawTask<F,T,S>::run
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.3.0/src/raw.rs:511:20
16: async_task::runnable::Runnable::run
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.3.0/src/runnable.rs:309:18
17: async_executor::Executor::run::{{closure}}::{{closure}}
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:235:21
18: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/future/mod.rs:91:19
19: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:529:33
20: async_executor::Executor::run::{{closure}}
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.1/src/lib.rs:242:31
21: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/future/mod.rs:91:19
22: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.12.0/src/future.rs:529:33
23: async_io::driver::block_on
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-io-1.7.0/src/driver.rs:142:33
24: async_global_executor::reactor::block_on::{{closure}}
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.2.0/src/reactor.rs:3:18
25: async_global_executor::reactor::block_on
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.2.0/src/reactor.rs:12:5
26: async_global_executor::threading::thread_main_loop::{{closure}}::{{closure}}
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.2.0/src/threading.rs:95:17
27: std::thread::local::LocalKey<T>::try_with
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/thread/local.rs:442:16
28: std::thread::local::LocalKey<T>::with
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/thread/local.rs:418:9
29: async_global_executor::threading::thread_main_loop::{{closure}}
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.2.0/src/threading.rs:89:13
30: std::panicking::try::do_call
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
31: ___rust_try
32: std::panicking::try
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
33: std::panic::catch_unwind
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
34: async_global_executor::threading::thread_main_loop
at /Users/mburr/.cargo/registry/src/github.com-1ecc6299db9ec823/async-global-executor-2.2.0/src/threading.rs:88:12
35: core::ops::function::FnOnce::call_once
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
sdroege commented
That's expected from the code, see
async-tungstenite/examples/echo-server.rs
Lines 50 to 53 in f5025ed
If you want to handle the error gracefully then replace the expect()
with actual error handling. This would happen for example when the other side simply closes the connection.