Summary
Messages sent via client.send_message() always use enc type="pkmsg" (prekey messages) instead of reusing established Signal protocol sessions (enc type="msg"). The WhatsApp server ACKs the messages, but recipients never receive them — likely because the prekey bundles are exhausted or the sessions established during encryption aren't persisted between sends.
Reproduction
- Authenticate a new session (QR code pairing)
- Send a message to a contact — works initially
- Send another message to the same contact — still uses
pkmsg
- Recipient never sees the messages (server ACKs but delivery fails silently)
Log Evidence
Every outgoing message uses pkmsg for the recipient, even after multiple sends to the same contact:
<!-- First send -->
<message id="3EB041..." to="49157...@s.whatsapp.net" type="text">
<participants>
<to jid="49157...@s.whatsapp.net"><enc type="pkmsg" v="2"/></to>
<to jid="39366...@s.whatsapp.net"><enc type="msg" v="2"/></to> <!-- own device: reused -->
</participants>
</message>
<!-- Second send to same contact — still pkmsg, should be msg -->
<message id="3EB0F1..." to="49157...@s.whatsapp.net" type="text">
<participants>
<to jid="49157...@s.whatsapp.net"><enc type="pkmsg" v="2"/></to>
<to jid="39366...@s.whatsapp.net"><enc type="msg" v="2"/></to>
</participants>
</message>
Note: the sender's own devices correctly use enc type="msg" (established session), so session persistence works for self-devices but not for remote contacts.
Expected Behavior
After the first pkmsg to a contact, subsequent sends should use enc type="msg" (the Signal session established during the first send should be persisted and reused).
Environment
- whatsapp-rust v0.4.1
- Custom
ProtocolStore implementation backed by SQLite (put_session/get_session using INSERT OR REPLACE)
- macOS, Rust nightly
Workaround
Deleting the database and re-pairing temporarily fixes it, but the issue recurs after some time.
Possible Cause
The session established during send_message_impl() may not be getting committed to the store, or the session lookup is using a different address format than what was stored. The fact that self-device sessions work correctly suggests the issue is specific to how remote contact sessions are keyed/stored.
Summary
Messages sent via
client.send_message()always useenc type="pkmsg"(prekey messages) instead of reusing established Signal protocol sessions (enc type="msg"). The WhatsApp server ACKs the messages, but recipients never receive them — likely because the prekey bundles are exhausted or the sessions established during encryption aren't persisted between sends.Reproduction
pkmsgLog Evidence
Every outgoing message uses
pkmsgfor the recipient, even after multiple sends to the same contact:Note: the sender's own devices correctly use
enc type="msg"(established session), so session persistence works for self-devices but not for remote contacts.Expected Behavior
After the first
pkmsgto a contact, subsequent sends should useenc type="msg"(the Signal session established during the first send should be persisted and reused).Environment
ProtocolStoreimplementation backed by SQLite (put_session/get_sessionusingINSERT OR REPLACE)Workaround
Deleting the database and re-pairing temporarily fixes it, but the issue recurs after some time.
Possible Cause
The session established during
send_message_impl()may not be getting committed to the store, or the session lookup is using a different address format than what was stored. The fact that self-device sessions work correctly suggests the issue is specific to how remote contact sessions are keyed/stored.