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

"Rate limit exceeded" when sending a single message #27

Closed
lushing opened this issue May 4, 2021 · 4 comments
Closed

"Rate limit exceeded" when sending a single message #27

lushing opened this issue May 4, 2021 · 4 comments

Comments

@lushing
Copy link
Contributor

lushing commented May 4, 2021

When using the Manager's send_message method, I will always run into the following error:

[INFO  libsignal_service::sender] establishing new session with ProtocolAddress { name: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", device_id: 1 }
[WARN  presage::config::sled] trusting new identity ProtocolAddress { name: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", device_id: 1 }
[INFO  libsignal_protocol::session] set_unacknowledged_pre_key_message for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.1 with preKeyId: XXXXXXXX
[INFO  libsignal_protocol::state::session] Skipping archive, current session state is fresh
[INFO  libsignal_protocol::session] set_unacknowledged_pre_key_message for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.2 with preKeyId: XXX
[INFO  libsignal_protocol::session_cipher] Building PreKeyWhisperMessage for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.1 with preKeyId: XXXXXXXX
[INFO  libsignal_protocol::session] set_unacknowledged_pre_key_message for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.2 with preKeyId: XXX
[INFO  libsignal_protocol::session_cipher] Building PreKeyWhisperMessage for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.1 with preKeyId: XXXXXXXX
[INFO  libsignal_protocol::session] set_unacknowledged_pre_key_message for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.2 with preKeyId: XXX
[INFO  libsignal_protocol::session_cipher] Building PreKeyWhisperMessage for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.1 with preKeyId: XXXXXXXX
[INFO  libsignal_protocol::session] set_unacknowledged_pre_key_message for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.2 with preKeyId: XXX
[INFO  libsignal_protocol::session_cipher] Building PreKeyWhisperMessage for: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.1 with preKeyId: XXXXXXXX
Error: libsignal-service sending error: Rate limit exceeded

Caused by:
    0: Rate limit exceeded
    1: Rate limit exceeded

This occurs whenever I try to send only one message to another Signal account. I've tried many variations of the code, but always with the same result.

Here is the relevant code:

let number = phonenumber::parse(None, "+17607067425")?;

let timestamp = std::time::SystemTime::now()
    .duration_since(UNIX_EPOCH)
    .expect("negative time")
    .as_millis() as u64;

let message = ContentBody::DataMessage(DataMessage {
    body: Some("test"),
    timestamp: Some(timestamp),
    ..Default::default()
});

manager.send_message(number, message, timestamp).await?;
@boxdot
Copy link
Collaborator

boxdot commented May 5, 2021

I am using this method in Gurk without any problems. It might be that you linked/unlinked a device too often in a short period of time, which leads to rate limiting. There is also a simple whoami method that gives you your ID back. Maybe you can try this one to see if it is also rate-limited.

@gferon
Copy link
Collaborator

gferon commented May 5, 2021

I discovered a bug but I committed a fix sneakily as part of #20, sorry for that. I'll try to be more transparent in the future, if that can help!

The problem is something we've already had to deal with in the past, and is related to the way we store sessions.

The switch to the Rust version of libsignal-protocol re-introduced the bug because the std::fmt::Display implementation of ProtocolAddress writes {phone_number}.{device_id} and we were expecting {phone_number}-{device_id} in the implementation of StoreSessionExt::get_sub_devices_sessions.

@gferon
Copy link
Collaborator

gferon commented May 5, 2021

Forgot to ask: @lushing could you try again with the latest commit from main and report back here?

@lushing
Copy link
Contributor Author

lushing commented May 5, 2021

@gferon This has indeed fixed the bug, and sending messages now works as expected. Thanks!

@lushing lushing closed this as completed May 5, 2021
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

No branches or pull requests

3 participants