#when deploy my server to google cloud functions it stop run at this line await client.initialize();

4 messages · Page 1 of 1 (latest)

ancient aurora
#

it works perfectly fine in my local functions emulator `const admin = require("firebase-admin");
const { Client, LocalAuth } = require("whatsapp-web.js");
const { onCall } = require("firebase-functions/v2/https");

admin.initializeApp();

const initializeAndSendMessage = async (userId) => {
return new Promise( async (resolve, reject) => {
console.log("Initializing WhatsApp client for user:", userId);
const client = new Client({
authStrategy: new LocalAuth({
clientId: userId,
}),
puppeteer: {
headless: true,
args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu"],
},
webVersionCache: {
type: "remote",
remotePath: "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
},
});

client.on("ready", async () => {
  console.log("Client is ready for user:", userId);
  resolve(client);
});

client.on("qr", async (qr) => {
  console.log("Storing QR-Code for user:", userId);
  // You can add your code to store the QR code here
});

client.on("authenticated", async () => {
  console.log("Authenticated for user:", userId);
});

client.on("auth_failure", async () => {
  console.log("Auth failure for user:", userId);
  reject(new Error("Authentication failed"));
});

client.on("disconnected", async () => {
  console.log("Client disconnected for user:", userId);
  // Handle disconnection if necessary
});

console.log("client.initialize:", userId);

await client.initialize();
});
};
`

inland citrus
#

cloud function is serverless server, it will only run for certain amount of time then go to sleep mode

ancient aurora
#

yes, so I decided to migrate to Hostinger VPS
But I'm facing a new issue which is that each user sends a message he uses a new chromium browser
is there a possibility to make each user run in his own tap in the same browser?
thanks for your answer

inland citrus
#

new tab or new window for me are the same, make sure they run on headless mode