Closed yelnyafacee closed 7 months ago
Hi there!
It's not a bug, it's because you're using LocalAuth
strategy and saving your session files inside your selected path.
According to wwebjs.dev - LocalAuth documentation, you need a persistent file system to save your session and restore it, the authenticated
event won't return your session.
Also, almost all (maybe all) whatsapp numbers at today are using multidevice. So, if you were looking at LegacySessionAuth
strategy to save your session as JSON object, it won't work at all.
I would recommend you to try RemoteAuth
strategy, using a free MongoDB cluster.
import { MongoStore } from 'wwebjs-mongo';
import mongoose from 'mongoose';
import dotenv from 'dotenv';
dotenv.config();
await mongoose.connect(process.env.MONGODB_URI!);
const store = new MongoStore({ mongoose });
const client = new Client({
authStrategy: new RemoteAuth({
store,
backupSyncIntervalMs: 300000, // in ms, minimum interval starts at 60000
clientId: `your-client-id`, // I would say it's required
dataPath: './your_sessions_path/', // optional
}),
restartOnAuthFail: true, // optional
puppeteer: {
headless: true,
args: [
'--no-sandbox',
// other node args
],
},
});
client.initialize();
Getting session in event client.on('authenticated')
is only available if you using LegacySessionAuth()
Hi, I am trying to send a message after the client is ready. The client is not getting ready for 2 minutes. But it is active on my mobile, not able to send messages. Kindly help me. Thanks in advance.
Hi, I am trying to send a message after the client is ready. The client is not getting ready for 2 minutes. But it is active on my mobile, not able to send messages. Kindly help me. Thanks in advance.
Try to update the lib version, you are probably running on an old version
Is there an existing issue for this?
Describe the bug
hi. my
session
object returned fromclient.on('authenticated', (session) => { ..... });
is alwaysundefined
no matter what, mynodejs
project is currently running fromlocalhost
here is my
index.js
:Expected behavior
session
object notundefined
Steps to Reproduce the Bug or Issue
node.js
projectindex.js
filenode index.js
Relevant Code
No response
Browser Type
Google Chrome
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
Windows 11
Additional context
No response