boxdot / gurk-rs

Signal Messenger client for terminal
GNU Affero General Public License v3.0
440 stars 33 forks source link

Linking device appears to silently fail #250

Closed OrderlyUnicode closed 6 months ago

OrderlyUnicode commented 8 months ago

Upon running gurk for a second time (and subsequent times after) the app simply creates a new QR code to use for linking the device. My guess is that it is failing the first time and afterwards, because under "linked devices" on Signal on my phone, the only link shown is the one I established with the official app. No error is being shown, even when using the --verbose argument, so I assume it's silently failing and trying again when I try to run it again.

On the off chance it's relevant, I'm using the gurk-bin package from the AUR, version 0.4.0-1. The device I'm using to link it via QR code is running version 6.37.2 of the official Signal app on Android.

devnibo commented 8 months ago

Same error on my side. I also use the AUR package gurk-bin.

devnibo commented 8 months ago

I tried to fix it myself but didn't succeed yet. What I tried so far is adding anyhow::Error in two places. That didn't work.

diff --git a/src/main.rs b/src/main.rs
index b9aae90..c5f5a3c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -91,7 +91,7 @@ pub enum Event {
     AppEvent(gurk::event::Event),
 }

-async fn run_single_threaded(relink: bool) -> anyhow::Result<()> {
+async fn run_single_threaded(relink: bool) -> anyhow::Result<(), anyhow::Error> {
     let (mut signal_manager, config) = signal::ensure_linked_device(relink).await?;

     let mut storage: Box<dyn Storage> = if config.sqlite.enabled {
diff --git a/src/signal/mod.rs b/src/signal/mod.rs
index 4490ec1..bb9e510 100644
--- a/src/signal/mod.rs
+++ b/src/signal/mod.rs
@@ -30,7 +30,7 @@ pub type GroupIdentifierBytes = [u8; GROUP_IDENTIFIER_LEN];
 ///    path.
 pub async fn ensure_linked_device(
     relink: bool,
-) -> anyhow::Result<(Box<dyn SignalManager>, Config)> {
+) -> anyhow::Result<(Box<dyn SignalManager>, Config), anyhow::Error> {
     let config = Config::load_installed()?;
     let db_path = config
         .as_ref()

Maybe someone could point me in the right direction?

boxdot commented 8 months ago

Thank you for reporting. I will try to improve the error reporting and come back.

SloppyPuppy commented 7 months ago

Bump, same issue running gurk-bin 0.4.0-1, signal offical 6.39.1, also to note in signal app it says link successful, but it never shows up with a newly linked device, and if I spam trying to link it shows network error instead of link successful.

boxdot commented 7 months ago

Bump, same issue running gurk-bin 0.4.0-1, signal offical 6.39.1, also to note in signal app it says link successful, but it never shows up with a newly linked device, and if I spam trying to link it shows network error instead of link successful.

If you link to often, they definitely rate limit you. JFYI: I am still looking into this issue.

dvn0 commented 7 months ago

I'm also experiencing something similar. Using the latest release of gurk (0.4.1) and I can get the initial link to show up on my official signal client but when I close and open gurk then it tries to link again.

boxdot commented 7 months ago

I just tried to link with fresh installation. Basically, the application hangs on

2023-11-15T14:46:08.758967Z  INFO presage::manager: waiting for contacts sync for up to 60 seconds

Stopping it with CTRL-C and restarting, start an empty application which works though.

chmanie commented 7 months ago

Seems to work with the newest build! Although my sent messages are not synced from desktop to phone. Don't know if this has been an issue before.

boxdot commented 7 months ago

Seems to work with the newest build! Although my sent messages are not synced from desktop to phone. Don't know if this has been an issue before.

There was a bug which did not handle sync messages from other devices in groups. It was recently fixed here: https://github.com/boxdot/gurk-rs/pull/251. But there is another one, which is more subtle. My guess is that something is wrong with syncing prekeys. This is also what I am debugging right now.

jacksongoode commented 6 months ago

Currently failing to link with the latest build.

boxdot commented 6 months ago

Digging deeper. The provisioning stage succeeds in presage, but what fails is the confirmation stage confirm_device.

[2023-12-12T21:40:01Z DEBUG libsignal_service_hyper::push_service] HTTP request PUT https://chat.staging.signal.org/v1/devices/37e7dd74-4c95-4b8a-adff-26b6a3043a50.1702417201329:Eh2fKUYZX6U0mH7c3WelCrbpajw0Wl_LILpnrpHR7vg=
[2023-12-12T21:40:02Z TRACE libsignal_service_hyper::push_service] Unhandled response 405 with body: {"code":405,"message":"HTTP 405 Method Not Allowed"}
ProvisioningError(ServiceError(UnhandledResponseCode { http_code: 405 }))
pawamoy commented 4 months ago

Hmmm, gurk-bin from AUR is still in v0.4.0, while thix fix was released in v0.4.2.