You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is this a problem caused by your code, or is it specifically because of the library?
I have double-checked my code carefully.
Describe the bug.
After successfully authorizing with whatsapp-web.js and sending messages, everything works fine for a certain period. However, after some time has passed (e.g., 20-30 minutes), messages stop being delivered. The sendMessage method still returns a response indicating successful delivery, but the messages are not received by the recipient.
Meanwhile, other requests, such as getChats, continue to work without issues. Resetting the session allows messages to be delivered again temporarily, but the problem eventually reoccurs.
Expected Behavior
Messages should continue to be delivered after authorization, regardless of the time elapsed since the session was initialized.
Steps to Reproduce the Bug or Issue
Steps to Reproduce:
Initialize a client with RemoteAuth, saving the session to S3.
Authorize successfully.
Send a message using client.sendMessage.
Wait for some time (approximately 20-30 minutes).
Attempt to send another message.
//Send message
import { initializeClient } from './initializeClient'
import { transformMessage } from './transformMessage'
import { UnreadMessage, WhatsAppPayload, WhatsAppResponse } from '../interfaces'
I can confirm this bug. Apparently it only affected new connections from my running app. I just don't know exactly when this started for new connections, but I believe it was about 2 months ago.
Is there an existing issue for this?
Is this a problem caused by your code, or is it specifically because of the library?
Describe the bug.
After successfully authorizing with whatsapp-web.js and sending messages, everything works fine for a certain period. However, after some time has passed (e.g., 20-30 minutes), messages stop being delivered. The sendMessage method still returns a response indicating successful delivery, but the messages are not received by the recipient.
Meanwhile, other requests, such as getChats, continue to work without issues. Resetting the session allows messages to be delivered again temporarily, but the problem eventually reoccurs.
Expected Behavior
Messages should continue to be delivered after authorization, regardless of the time elapsed since the session was initialized.
Steps to Reproduce the Bug or Issue
Steps to Reproduce:
Initialize a client with RemoteAuth, saving the session to S3.
Authorize successfully.
Send a message using client.sendMessage.
Wait for some time (approximately 20-30 minutes).
Attempt to send another message.
//Send message
import { initializeClient } from './initializeClient'
import { transformMessage } from './transformMessage'
import { UnreadMessage, WhatsAppPayload, WhatsAppResponse } from '../interfaces'
export async function sendMessage(payload: WhatsAppPayload): Promise<WhatsAppResponse> {
const { number, message, webhook_auth_key } = payload
const { client, connected, disconnect } = await initializeClient(webhook_auth_key)
const chatId = number!.includes('@c.us') ? number :
${number}@c.us
const send = await client.sendMessage(chatId!, message!)
await new Promise((resolve) => {
client.on('message_ack', (msg: any, ack: any) => {
if (msg.id._serialized === send.id._serialized) {
if (ack > 0) {
resolve()
}
}
})
})
const transformedMessage = transformMessage(send)
await disconnect()
return { data: transformedMessage, connected }
}
//initialize Client
import { Client, RemoteAuth } from 'whatsapp-web.js'
import { AwsS3Store } from 'wwebjs-aws-s3'
import {
S3Client,
PutObjectCommand,
HeadObjectCommand,
GetObjectCommand,
DeleteObjectCommand,
} from '@aws-sdk/client-s3'
export async function initializeClient(id: string): Promise<{
client: Client
connected: boolean
disconnect: () => Promise
}> {
const s3 = new S3Client({
region: 'my-region',
credentials: {
accessKeyId: 'my-key-id',
secretAccessKey: 'my-key',
},
})
const putObjectCommand = PutObjectCommand
const headObjectCommand = HeadObjectCommand
const getObjectCommand = GetObjectCommand
const deleteObjectCommand = DeleteObjectCommand
const store = new AwsS3Store({
bucketName: process.env.S3_BUCKET_NAME!,
remoteDataPath: 'path-to-my-sessions/',
s3Client: s3,
putObjectCommand,
headObjectCommand,
getObjectCommand,
deleteObjectCommand,
})
const client = new Client({
puppeteer: {
args: ['--no-sandbox'],
},
authStrategy: new RemoteAuth({
clientId: id,
store: store,
backupSyncIntervalMs: 600000,
}),
})
return new Promise((resolve) => {
client.on('ready', () => {
resolve({
client,
connected: true,
disconnect: async () => {
await client.destroy()
},
})
})
})
}
WhatsApp Account Type
Standard
Browser Type
Chromium
Operation System Type
Mac
Phone OS Type
iOS 18.1.1
WhatsApp-Web.js Version
1.26.0
WhatsApp Web Version
2.3000.1019158277
Node.js Version
v18.20.5
Authentication Strategy
RemoteAuth
Additional Context
No response
The text was updated successfully, but these errors were encountered: