#remote auth, mongodb empthy zip session
8 messages · Page 1 of 1 (latest)
i fixed the error, for anyone having the same, before you upload the session you need to close the client
kindly share code
const { Client,RemoteAuth } = require('whatsapp-web.js');
const { MongoStore } = require('wwebjs-mongo');
const qrcode = require('qrcode-terminal');
const mongoose = require('mongoose');
require("dotenv").config();
async function initializeWhatsApp(userId) {
return new Promise((resolve, reject) => {
mongoose.connect(process.env.MONGODB_URI).then(() => {
let store = new MongoStore({ mongoose: mongoose });
const client = new Client({
puppeteer: {
args: ['--no-sandbox', '--disable-setuid-sandbox'],
headless:false,
},
authStrategy: new RemoteAuth({
clientId: userId,
store: store,
backupSyncIntervalMs: 300000
}),
webVersionCache: {
type: 'remote',
remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html',
}
});
client.once('ready', () => {
console.log('Client is ready!');
resolve(client);
client.destroy(); //client destroy as soon it is auth so the session can be saved correctly
});
client.on('qr', (qr) => {
console.log('QR RECEIVED', qr);
qrcode.generate(qr, {small: true});
});
client.on("authenticated", () => {
console.log("Authentication successful");
});
client.on("remote_session_saved", () => {
console.log("Session saved");
});
client.initialize().catch(reject);
}).catch(reject);
});
}
in this way the average size of the session on mongo is around 1 or 2 mb
thnx
no problem, have fun
it's need to scan every time when restart server no meaning of save session in db.