#remote auth, mongodb empthy zip session

8 messages · Page 1 of 1 (latest)

past oyster
#

Hello, i have trouble on remoteAuth with mongodb, the session .zip file seams to be empty when uploaded, so it is when downloaded, i tried to use the known fix for the zip file changing the remoteAuth.js, but without result.

past oyster
#

i fixed the error, for anyone having the same, before you upload the session you need to close the client

past oyster
# exotic sandal 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

exotic sandal
#

thnx

past oyster
#

no problem, have fun

exotic sandal