Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable keep-alive on unidentified websocket #175

Closed
wants to merge 6 commits into from

Conversation

gferon
Copy link
Collaborator

@gferon gferon commented May 31, 2023

and initialize websockets in Manager.

@boxdot could you try this out?

@gferon gferon requested a review from boxdot May 31, 2023 22:56
@gferon gferon marked this pull request as draft June 1, 2023 08:11
@Schmiddiii
Copy link
Contributor

Not sure what to look out for, but sending messages seems to work fine. Also probably noted a copy-and-paste error.

presage/src/manager.rs Outdated Show resolved Hide resolved
}

async fn unidentified_websocket(&self) -> Result<SignalWebSocket, Error<C::Error>> {
if let Some(ws) = self.state.unidentified_websocket.borrow().as_ref() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a similar code which caches the unidentified websocket. The question is: what happens if connection is lost to it? Then we have a cached broken websocket. Right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, this is unhandled, which is really bad and the reason why I haven't merged this PR yet.

@Schmiddiii
Copy link
Contributor

When trying this, I get the following panic after linking:

thread '<unnamed>' panicked at 'web socket request handler not in use', /path/to/flare/build/cargo-home/git/checkouts/libsignal-service-rs-e91a0c40cab55da9/8305357/libsignal-service/src/messagepipe.rs:60:14
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: core::option::Option<T>::expect
             at /build/rustc-1.71.1-src/library/core/src/option.rs:898:21
   4: libsignal_service::messagepipe::MessagePipe::run::{{closure}}
             at ./build/cargo-home/git/checkouts/libsignal-service-rs-e91a0c40cab55da9/8305357/libsignal-service/src/messagepipe.rs:58:26
   5: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/future/map.rs:55:37
   6: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/lib.rs:91:13
   7: <futures_util::stream::once::Once<Fut> as futures_core::stream::Stream>::poll_next
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/once.rs:46:33
   8: <futures_util::future::future::IntoStream<F> as futures_core::stream::Stream>::poll_next
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/lib.rs:102:13
   9: futures_util::stream::select_with_strategy::poll_side
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/select_with_strategy.rs:220:28
  10: futures_util::stream::select_with_strategy::poll_inner
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/select_with_strategy.rs:243:11
  11: <futures_util::stream::select_with_strategy::SelectWithStrategy<St1,St2,Clos,State> as futures_core::stream::Stream>::poll_next
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/select_with_strategy.rs:270:17
  12: <futures_util::stream::select::Select<St1,St2> as futures_core::stream::Stream>::poll_next
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/select.rs:115:9
  13: <futures_util::stream::stream::filter_map::FilterMap<St,Fut,F> as futures_core::stream::Stream>::poll_next
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/filter_map.rs:79:47
  14: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-core-0.3.28/src/stream.rs:120:9
  15: futures_util::stream::stream::StreamExt::poll_next_unpin
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/mod.rs:1632:9
  16: <futures_util::stream::stream::next::Next<St> as core::future::future::Future>::poll
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/next.rs:32:9
  17: presage::manager::Manager<C,presage::manager::Registered>::receive_messages_stream::{{closure}}::{{closure}}::{{closure}}
             at ./build/cargo-home/git/checkouts/presage-4ae65a48cf0619a5/e2ab47c/presage/src/manager.rs:895:55
  18: <futures_util::stream::unfold::Unfold<T,F,Fut> as futures_core::stream::Stream>::poll_next
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/unfold.rs:107:33
  19: <core::pin::Pin<P> as futures_core::stream::Stream>::poll_next
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-core-0.3.28/src/stream.rs:120:9
  20: futures_util::stream::stream::StreamExt::poll_next_unpin
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/mod.rs:1632:9
  21: <futures_util::stream::stream::next::Next<St> as core::future::future::Future>::poll
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/stream/stream/next.rs:32:9
  22: <futures_util::future::future::fuse::Fuse<Fut> as core::future::future::Future>::poll
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/future/fuse.rs:84:26
  23: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /build/rustc-1.71.1-src/library/core/src/future/future.rs:125:9
  24: futures_util::future::future::FutureExt::poll_unpin
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/future/mod.rs:562:9
  25: flare::backend::manager_thread::command_loop::{{closure}}::{{closure}}::{{closure}}
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/async_await/select_mod.rs:321:13
  26: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /build/rustc-1.71.1-src/library/core/src/ops/function.rs:294:13
  27: flare::backend::manager_thread::command_loop::{{closure}}::{{closure}}
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/async_await/select_mod.rs:321:13
  28: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/poll_fn.rs:56:9
  29: flare::backend::manager_thread::command_loop::{{closure}}
             at ./src/backend/manager_thread.rs:328:21
  30: flare::backend::manager_thread::ManagerThread::new::{{closure}}::{{closure}}::{{closure}}::{{closure}}
             at ./src/backend/manager_thread.rs:96:78
  31: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/park.rs:282:63
  32: tokio::runtime::coop::with_budget
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/coop.rs:107:5
  33: tokio::runtime::coop::budget
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/coop.rs:73:5
  34: tokio::runtime::park::CachedParkThread::block_on
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/park.rs:282:31
  35: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context/blocking.rs:66:9
  36: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
  37: tokio::runtime::context::runtime::enter_runtime
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context/runtime.rs:65:16
  38: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
  39: tokio::runtime::runtime::Runtime::block_on
             at ./build/cargo-home/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/runtime.rs:349:45
  40: flare::backend::manager_thread::ManagerThread::new::{{closure}}::{{closure}}::{{closure}}
             at ./src/backend/manager_thread.rs:91:17
  41: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /build/rustc-1.71.1-src/library/core/src/panic/unwind_safe.rs:271:9
  42: std::panicking::try::do_call
             at /build/rustc-1.71.1-src/library/std/src/panicking.rs:500:40
  43: __rust_try
  44: std::panicking::try
             at /build/rustc-1.71.1-src/library/std/src/panicking.rs:464:19
  45: std::panic::catch_unwind
             at /build/rustc-1.71.1-src/library/std/src/panic.rs:142:14
  46: flare::backend::manager_thread::ManagerThread::new::{{closure}}::{{closure}}
             at ./src/backend/manager_thread.rs:90:25

@gferon
Copy link
Collaborator Author

gferon commented Nov 20, 2023

This was done in #203 and works well!

@gferon gferon closed this Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants