-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QR Scan Doubles Triggers on Linux Server #3081
Comments
I have been experiencing the same issue for the past 7 days. After scanning the first QR code, another QR code is immediately generated, which starts with "Undefined." Then, after a few seconds, a new QR code is generated that does not start with "Undefined." However, if I scan this new code, the same cycle repeats. |
This problem only occurs with Indian WhatsApp numbers. |
server is not located in India, but the numbers are Indians. |
Yes, my server is located in India, and the number is also Indian. |
Tried this but not work :
|
Deploy server in Banglore region and Nodejs 18.15.0 works for me. |
Is there an existing issue for this?
Describe the bug
When I run the code on my linux centos server, and when I trigger the QR.
When I scan the QR immediately another QR is triggered. I don't understand and both of the QR's don't work it says Couldn't login on my phone. On my local machine it works perfectly fine.
I tried switching to a different server where it used to work before but it doesn't my previously scanned numbers are working but scan new ones
Expected behavior
When scanning it should have scanned and shouldn't have a second qr. Regardless of that scanning both of the QR's don't work
Steps to Reproduce the Bug or Issue
Relevant Code
const { Client, LocalAuth, MessageMedia } = require("whatsapp-web.js");
const {
updateSessionStatus,
getSessionByClientId,
insertUpdateSession,
} = require("../models/sessionsModel");
const { sendResponse } = require("../utils/responseHelper");
const allSessionsObjects = {};
const qrcode = require("qrcode-terminal");
const axios = require("axios");
const date = require("./dateHelper");
const {
insertUpdateTask,
getTasks,
updateTaskStatus,
getCompletedTasks,
deleteTask,
getEmployee,
getEmployees,
getTask,
getEmployeeTasks,
getExcelTasks,
getEmployeeById,
} = require("../models/todoModel");
const { insertUpdateLedger, getLedger, getLedgers, deleteLedger } = require("../models/ledgerModel")
const { insertUpdateTransaction, getTransaction, getTransactions, deleteTransaction } = require("../models/transactionModel")
const ExcelJS = require("exceljs");
function clientSession(session, type, sessionAuthenticated, data, req, res) {
/*
Type:
0 = During Reinitialisation
1 = Other
Type is created in order to not auto send QR code
in case someone disconnected when the server not active
which will result in sending QR without anyone requesting
causing an error of sending HTTP multiple headers
*/
const client = new Client({
puppeteer: {
headless: true,
args: ["--no-sandbox"],
},
authStrategy: new LocalAuth({
clientId: session,
}),
webVersionCache: {
type: "remote",
remotePath:
"https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
},
});
client.on("qr", async (qr) => {
if (!type) {
const sessionResult = await getSessionByClientId(session);
if (sessionResult.length > 0) updateSessionStatus(0, session);
qrcode.generate(qr, { small: true });
sendResponse(req, res, {
httpStatus: "200",
errorCode: 0,
data: { qr: qr },
message: "QR Code Generated",
});
} else {
console.log(
${session} is Expired!
);updateSessionStatus(0, session);
client.destroy();
}
});
const timeout = setTimeout(() => {
if (!sessionAuthenticated) {
console.log("Client destroyed due to non-authenticated session.");
client.destroy();
return;
}
}, 90000); // 60,000 milliseconds (60 seconds)
client.on("authenticated", () => {
if (!sessionAuthenticated) clearTimeout(timeout); // Cancel the destruction timer if authenticated
console.log(
${session} is Authenticated!
);});
client.on("ready", async () => {
console.log(
${session} is Ready!
);if (!type) await insertUpdateSession(data);
allSessionsObjects[session] = client;
});
client.on("disconnected", async () => {
console.log(
${session} is Expired!
);await updateSessionStatus(0, session);
client.destroy();
return;
});
client.on("message", async (msg) => {
if (session === "9594126533") {
try {
var receipents = String(msg.from);
receipents = receipents
.substring(0, receipents.indexOf("@"))
.replace("@", "");
});
client.initialize();
}
module.exports = { clientSession, allSessionsObjects };
Browser Type
Chromium
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
OS: Linux Centos7
Phone: Android (Samsung S22)
whatsapp-web.js - https://github.com/Julzk/whatsapp-web.js/tarball/jkr_hotfix_7
Whatsapp Web Version - https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html
Node Version: 16.20.2
Additional context
The text was updated successfully, but these errors were encountered: