dyule / wamp-rs

Implementation of Web Application Messaging Protocol in Rust
MIT License
22 stars 7 forks source link

Panic when the websocket connection fails (no result produced) #10

Open fin-ger opened 7 years ago

fin-ger commented 7 years ago

When trying to connect to a websocket server that is not running a panic is produced instead of a proper result.

INFO:endpoint: Connecting
INFO:ws: Queuing connection to ws://127.0.0.1:8090/ws
DEBUG:wamp::client: Cloning tranceiver
DEBUG:ws::handshake: Built request from URL:
GET /ws HTTP/1.1
Connection: Upgrade
Host: 127.0.0.1:8090
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: eZXKaj+r5Va/l1APMtWBTw==
Upgrade: websocket

DEBUG:ws::io: Shutting down websocket client.
DEBUG:ws::factory: Factory received WebSocket shutdown request.
DEBUG:wamp::client: Result of connection: Ok(())
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /checkout/src/libcore/result.rs:859
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:371
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:511
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:495
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:471
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:69
   9: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:29
  10: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/result.rs:737
  11: wamp::client::Connection::connect
             at src/client.rs:208
  12: endpoint::main
             at examples/endpoint.rs:37
  13: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  14: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:433
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:57
  15: main
  16: __libc_start_main
  17: _start

Interestingly the connection result is Ok although no connection was established. The panic makes it hard to handle a not-running server.