-
-
Notifications
You must be signed in to change notification settings - Fork 866
Open
Description
We have several WhatsApp clients that use the same sqllite3 database (using PostgreSQL is not possible).
When sending multiple messages from multiple clients, there is a problem saving the session cache; I see this issue multiple times in the logs.
failed to save cached sessions: failed to store cached sessions: transaction: begin: SQL logic error: cannot start a transaction within a transaction (1)
Message sending function:
func WhatsAppSendText(ctx context.Context, jid string, rjid string, message string) (string, error) {
if WhatsAppClient[jid] != nil {
var err error
// Make Sure WhatsApp Client is OK
err = WhatsAppClientIsOK(jid)
if err != nil {
return "", err
}
// Make Sure rJID is Proper JID Type
composeRJID := WhatsAppComposeJID(rjid)
// Set Chat Presence to Composing
WhatsAppComposeStatus(ctx, jid, composeRJID, true, false)
// Compose WhatsApp Proto
content := &waE2E.Message{
Conversation: proto.String(message),
}
msgId := WhatsAppClient[jid].GenerateMessageID()
SendRequestExtra := whatsmeow.SendRequestExtra{
ID: msgId,
Peer: false,
}
// Send WhatsApp Message Proto
_, err = WhatsAppClient[jid].SendMessage(ctx, composeRJID, content, SendRequestExtra)
if err != nil {
return "", err
}
// Set Chat Presence to Paused
WhatsAppComposeStatus(ctx, jid, composeRJID, false, false)
return msgId, nil
}
// Return Error WhatsApp Client is not Valid
return "", errors.New("WhatsApp Client is not Valid")
}
How can this behavior be corrected?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels