Skip to content
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

Closed
1 task done
MohammedMukarramMenn opened this issue Jun 6, 2024 · 7 comments
Closed
1 task done

QR Scan Doubles Triggers on Linux Server #3081

MohammedMukarramMenn opened this issue Jun 6, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@MohammedMukarramMenn
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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

  1. Trigger QR event
  2. Scan it
  3. Happend to me on Linux server

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("@", "");

    var cmd = msg.body.toLowerCase();

    if (receipents.indexOf("-") != -1) {
      receipents = receipents
        .substring(0, receipents.indexOf("-"))
        .replace("-", "");
    }

    if (receipents.startsWith("91") && receipents.length >= 12)
      receipents = receipents.substring(2);

    if (cmd.includes("create")) {
      const employee = await getEmployee(receipents);

      if (employee.length) {
        const taskName = cmd
          .substring(cmd.indexOf("create") + "create".length)
          .trim();

        if (!taskName) {
          msg.reply(
            "Please enter the task title.\n*Example:*\nCreate Check Mail"
          );
          return;
        }
        const data = {
          title: taskName,
          emp_id: employee[0].emp_id,
          datetimecreated: date.todayDateTime,
        };

        const result = await insertUpdateTask(data);

        if (result.affectedRows > 0) {
          msg.reply("Task Created Succesfully");
        }
      }
    } else if (cmd.includes("tasks")) {
      const employee = await getEmployee(receipents);

      if (employee.length) {
        const result = await getTasks(employee[0].emp_id);
        if (result.length > 0) {
          // Group tasks by date
          const groupedTasks = result.reduce((acc, task) => {
            const datetimecreated = new Date(task.datetimecreated);
            const date = datetimecreated.toLocaleDateString("en-US", {
              month: "long",
              day: "numeric",
              year: "numeric",
            });
            if (!acc[date]) {
              acc[date] = [];
            }
            acc[date].push(task);
            return acc;
          }, {});

          // Format tasks for display
          let message = "";
          for (const date in groupedTasks) {
            if (groupedTasks.hasOwnProperty(date)) {
              message += `*${date}*\n`;
              message += groupedTasks[date]
                .map((task) => `${task.task_id}. ${task.title}`)
                .join("\n");
              message += "\n";
            }
          }

          msg.reply(message);
        } else {
          msg.reply("You have no pending tasks");
        }
      }
    } else if (cmd.includes("done")) {
      const employee = await getEmployee(receipents);
      if (employee.length) {
        const taskId = cmd
          .substring(cmd.indexOf("done") + "done".length)
          .trim();
        if (!taskId) {
          msg.reply(
            "Please enter the task id.\nYou can check the task id using\n\n*tasks*"
          );
          return;
        }
        const task = await getTask(taskId);

        if (task && task[0].emp_id == employee[0].emp_id) {
          const data = {
            task_id: taskId,
            datetimemodified: date.todayDateTime,
            is_completed: 1,
          };
          const manager = "91" + employee[0].m_no + "@c.us";

          const result = await updateTaskStatus(data);

          if (result.affectedRows > 0) {
            msg.reply("Task has been Marked Completed");
            await client.sendMessage(
              manager,
              employee[0].name +
              " has just finished doing:\n  " +
              task[0].title
            );
          }
        } else {
          msg.reply(
            "This task number doesn't exist or hasn't been assigned to you."
          );
        }
      }
    } else if (cmd.includes("revert")) {
      const employee = await getEmployee(receipents);

      if (employee.length) {
        const taskId = cmd
          .substring(cmd.indexOf("revert") + "revert".length)
          .trim();
        if (!taskId) {
          msg.reply(
            "Please enter the task id.\nYou can check the task id using\n\n*tasks*"
          );
          return;
        }
        const task = await getTask(taskId);

        if (task && task[0].emp_id == employee[0].emp_id) {
          const data = {
            task_id: taskId,
            is_completed: 0,
          };

          const result = await updateTaskStatus(data);

          if (result.affectedRows > 0) {
            msg.reply("Task has been Reverted Succesfully!");
          }
        } else {
          msg.reply(
            "This task number doesn't exist or hasn't been assigned to you."
          );
        }
      }
    } else if (cmd.includes("completed")) {
      const employee = await getEmployee(receipents);

      if (employee.length) {
        const result = await getCompletedTasks(employee[0].emp_id);

        // Group tasks by start and end dates
        const tasksByStartEndDates = result.reduce((acc, task) => {
          const startDateKey = task.datetimecreated.substring(0, 10); // Extract yyyy-mm-dd for start date
          const endDateKey = task.datetimemodified.substring(0, 10); // Extract yyyy-mm-dd for end date
          const key = `${startDateKey}-${endDateKey}`;
          acc[key] = acc[key] || {
            startDate: task.datetimecreated,
            endDate: task.datetimemodified,
            tasks: [],
          };
          acc[key].tasks.push(task);
          return acc;
        }, {});

        // Format and display tasks by start and end dates
        const formattedTasks = Object.keys(tasksByStartEndDates)
          .map((dateKey) => {
            const { startDate, endDate, tasks } =
              tasksByStartEndDates[dateKey];
            const formattedStartDate = new Date(
              startDate
            ).toLocaleDateString("en-US", {
              month: "short",
              day: "numeric",
              year: "numeric",
            });
            const formattedEndDate = new Date(endDate).toLocaleDateString(
              "en-US",
              { month: "short", day: "numeric", year: "numeric" }
            );
            const taskList = tasks
              .map((task) => `${task.task_id}. ${task.title}`)
              .join("\n");
            let output = "";
            if (startDate !== endDate) {
              output += `Start: ${formattedStartDate}\n`;
              output += `End: ${formattedEndDate}\n`;
            } else {
              output += `${formattedStartDate}\n`;
            }
            output += `${taskList}`;
            return output;
          })
          .join("\n\n");

        msg.reply(`*Completed Tasks*:\n${formattedTasks}`);
      }
    } else if (cmd.includes("delete")) {
      const employee = await getEmployee(receipents);

      if (employee.length) {
        const taskId = cmd
          .substring(cmd.indexOf("delete") + "delete".length)
          .trim();
        if (!taskId) {
          msg.reply(
            "Please enter the task id.\nYou can check the task id using\n\n*tasks*"
          );
          return;
        }
        const task = await getTask(taskId);

        if (task && task[0].emp_id == employee[0].emp_id) {
          const result = await deleteTask(taskId);
          if (result.affectedRows > 0) {
            msg.reply("Task Deleted Succesfully");
          }
        } else {
          msg.reply(
            "This task number doesn't exist or hasn't been assigned to you."
          );
        }
      }
    } else if (cmd.includes("help")) {
      msg.reply(
        `Help:\n create {Task Name} - To Create a Task\n\n done {Task Number} - Mark Task as Completed\n\n revert {Task Number} - Revert Task from Completed\n\n tasks - Shows all Pending Tasks\n\n completed - Shows all Completed Tasks\n\n delete {Task number} Delete Task\n\n *For Managers*\n\n elist - To see list of Employees\n\n etasks {Employee Number} - To see pending list of the employees\n\n ecompleted {Employee Numbers} - To see the completed list of the employees\n\n report {Employee id} - To get an excel generate of all employees tasks`
      );
    } else if (cmd.includes("elist")) {
      const employee = await getEmployee(receipents);
      const employees = await getEmployees();
      if (employee.length) {
        if (employee[0].is_manager > 0) {
          const employeeList = employees
            .map((emp) => `${emp.emp_id}. ${emp.name}`)
            .join("\n");
          msg.reply(`*Employee List*:\n${employeeList}`);
        }
      }
    } else if (cmd.includes("etasks")) {
      const employee = await getEmployee(receipents);
      if (employee.length) {
        if (employee[0].is_manager > 0) {
          const taskId = cmd
            .substring(cmd.indexOf("etasks") + "etasks".length)
            .trim();
          if (!taskId) {
            msg.reply(
              "Please enter the employee id.\nYou can check the employee id using\n\n*elist*"
            );
            return;
          }
          const result = await getTasks(taskId);
          if (result.length > 0) {
            // Group tasks by date
            const groupedTasks = result.reduce((acc, task) => {
              const datetimecreated = new Date(task.datetimecreated);
              const date = datetimecreated.toLocaleDateString("en-US", {
                month: "long",
                day: "numeric",
                year: "numeric",
              });
              if (!acc[date]) {
                acc[date] = [];
              }
              acc[date].push(task);
              return acc;
            }, {});

            // Format tasks for display
            let message = "";
            for (const date in groupedTasks) {
              if (groupedTasks.hasOwnProperty(date)) {
                message += `*${date}*\n`;
                message += groupedTasks[date]
                  .map((task) => `${task.task_id}. ${task.title}`)
                  .join("\n");
                message += "\n";
              }
            }

            msg.reply(message);
          } else {
            msg.reply("No pending tasks");
          }
        }
      }
    } else if (cmd.includes("ecompleted")) {
      const employee = await getEmployee(receipents);
      if (employee.length) {
        if (employee[0].is_manager > 0) {
          const taskId = cmd
            .substring(cmd.indexOf("ecompleted") + "ecompleted".length)
            .trim();
          if (!taskId) {
            msg.reply(
              "Please enter the employee id.\nYou can check the employee id using\n\n*elist*"
            );
            return;
          }
          const result = await getCompletedTasks(taskId);
          if (result.length > 0) {
            // Group tasks by date
            const tasksByStartEndDates = result.reduce((acc, task) => {
              const startDateKey = task.datetimecreated.substring(0, 10); // Extract yyyy-mm-dd for start date
              const endDateKey = task.datetimemodified.substring(0, 10); // Extract yyyy-mm-dd for end date
              const key = `${startDateKey}-${endDateKey}`;
              acc[key] = acc[key] || {
                startDate: task.datetimecreated,
                endDate: task.datetimemodified,
                tasks: [],
              };
              acc[key].tasks.push(task);
              return acc;
            }, {});

            // Format and display tasks by start and end dates
            const formattedTasks = Object.keys(tasksByStartEndDates)
              .map((dateKey) => {
                const { startDate, endDate, tasks } =
                  tasksByStartEndDates[dateKey];
                const formattedStartDate = new Date(
                  startDate
                ).toLocaleDateString("en-US", {
                  month: "short",
                  day: "numeric",
                  year: "numeric",
                });
                const formattedEndDate = new Date(
                  endDate
                ).toLocaleDateString("en-US", {
                  month: "short",
                  day: "numeric",
                  year: "numeric",
                });
                const taskList = tasks
                  .map((task) => `${task.task_id}. ${task.title}`)
                  .join("\n");
                let output = "";
                if (startDate !== endDate) {
                  output += `Start: ${formattedStartDate}\n`;
                  output += `End: ${formattedEndDate}\n`;
                } else {
                  output += `${formattedStartDate}\n`;
                }
                output += `${taskList}`;
                return output;
              })
              .join("\n\n");

            msg.reply(`*Completed Tasks*:\n${formattedTasks}`);
          } else {
            msg.reply("No pending tasks");
          }
        }
      }
    } else if (cmd.includes("report")) {
      const employee = await getEmployee(receipents);
      if (employee.length) {
        if (employee[0].is_manager > 0) {
          const taskId = cmd
            .substring(cmd.indexOf("report") + "report".length)
            .trim();
          if (!taskId) {
            msg.reply(
              "Please enter the employee id.\nYou can check the employee id using\n\n*elist*"
            );
            return;
          }
          const results = await getExcelTasks(taskId);

          if (results.length) {
            const empDetails = await getEmployeeById(taskId);
            if (empDetails.length) {
              const workbook = new ExcelJS.Workbook();
              const worksheet = workbook.addWorksheet("Data");
              const fields = ["title", "start", "end"];

              const columns = [];
              fields.forEach((field) => {
                columns.push({
                  header: field.toUpperCase(),
                  key: field,
                  width: 20,
                });
              });
              worksheet.columns = columns;

              // Assuming 'row.start' and 'row.end' are the datetime values in the format 'yyyy-mm-dd hh:mm:ss'

              results.forEach((row) => {
                // Convert 'start' and 'end' datetime values to Date objects
                const startDate = new Date(row.start);
                if (row.end !== null) {
                  const endDate = new Date(row.end);
                  const formattedEndDate = endDate.toLocaleDateString(
                    "en-US",
                    {
                      month: "long",
                      day: "numeric",
                      year: "numeric",
                    }
                  );
                  row.end = formattedEndDate;
                }

                // Format 'start' and 'end' dates to 'Month Day, Year' format
                const formattedStartDate = startDate.toLocaleDateString(
                  "en-US",
                  { month: "long", day: "numeric", year: "numeric" }
                );

                // Update 'start' and 'end' values in the row object with formatted dates
                row.start = formattedStartDate;

                // Add the modified row to the worksheet
                worksheet.addRow(row);
              });

              const file =
                process.env.EXCEL + "/" + empDetails[0].name + ".xlsx";
              const modifiedNumber = "91" + receipents + "@c.us";
              workbook.xlsx
                .writeFile(file)
                .then(() => {
                  const media = MessageMedia.fromFilePath(file);
                  client.sendMessage(modifiedNumber, media, {
                    caption: " ",
                  });
                })
                .catch((err) => {
                  console.error("Error generating Excel file:", err);
                });

              worksheet.columns = columns;
            }
          }
        }
      }
    } else if (cmd.includes("cledger")) {
      // const employee = await getEmployee(receipents);
      if (receipents == "8104553818") {
        const taskName = cmd
          .substring(cmd.indexOf("cledger") + "cledger".length)
          .trim();

        if (!taskName) {
          msg.reply(
            "Please enter the ledger Name.\n*Example:*\nCledger Travel"
          );
          return;
        }
        const data = {
          name: taskName
        };

        const result = await insertUpdateLedger(data);

        if (result.affectedRows > 0) {
          msg.reply("Ledger Created Succesfully");
        }
      }
    } else if (cmd.includes("ledgers")) {
      if (receipents == "8104553818") {
        const result = await getLedgers();

        if (result.length > 0) {
          let message = "*Id* - *Ledger* - *Amount*\n";
          message += result.map(item => `${item.id} - ${item.name} - (${item.amount})`).join('\n');
          msg.reply(message);
        } else {
          msg.reply("No Ledgers Found");
        }
      }
    } else if (cmd.includes("dledger")) {
      if (receipents == "8104553818") {
        const taskId = cmd
          .substring(cmd.indexOf("dledger") + "dledger".length)
          .trim();
        if (!taskId) {
          msg.reply(
            "Please enter the ledger id you wish to delete.\nYou can check the ledger id using\n\n*ledgers*"
          );
          return;
        }
        const result = await deleteLedger(taskId);

        if (result.affectedRows > 0) {
          msg.reply("Ledger Deleted Succesfully");
        } else {
          msg.reply("Error occured in deleting");
        }
      }
    } else if (cmd.includes("transact")) {
      // const employee = await getEmployee(receipents);
      if (receipents == "8104553818") {
        const taskName = cmd
          .substring(cmd.indexOf("transact") + "transact".length)
          .trim();

        if (!taskName) {
          msg.reply(
            "Please enter the format of the transaction.\n\n*Payment Example:*\nTransact {ledgerid}-{amount}\n\n*Receipt Example:*\n\nTransact {ledgerid}+{amount}"
          );
          return;
        }

        const regex = /(\d+)\s*([\+\-])\s*(\d+)/;
        const match = taskName.match(regex);
        if (!match) {
          msg.reply("Invalid Format")
          return;
        }
        const ledgerId = parseInt(match[1], 10);
        const operator = match[2];
        const amount = parseInt(match[3], 10);

        const variableValue = operator === '+' ? 1 : operator === '-' ? 0 : null; // 1 = Receipt, 0 = Payment

        const data = {
          transaction_type: variableValue,
          ledger_id: ledgerId,
          narration: null,
          amount: amount,
          date: date.todayDateTime
        };

        const result = await insertUpdateTransaction(data);

        if (result.affectedRows > 0) {
          const ledger = await getLedger(ledgerId);
          let amount2 = ledger[0].amount;

          if (variableValue == 1)
            amount2 += amount
          else amount2 -= amount
          if (ledger.length) {
            const data2 = {
              id: ledgerId,
              name: ledger[0].name,
              amount: amount2
            }
            const result2 = await insertUpdateLedger(data2);
            if (result2.affectedRows > 0) {
              msg.reply("Transaction Recorded Successfully")
            }
          }
        }
      }
    } else if (cmd.includes("tlist")) {
      if (receipents == "8104553818") {
        const result = await getTransactions();
        if (result.length > 0) {
          const groupedTransactions = {};
          result.forEach(transaction => {
            const date = new Date(transaction.date).toLocaleDateString('en-US', {
              day: 'numeric',
              month: 'long',
              year: 'numeric'
            });
            if (!groupedTransactions[date]) {
              groupedTransactions[date] = [];
            }
            groupedTransactions[date].push(transaction);
          });

          let output = "";
          for (const date in groupedTransactions) {
            output += `*${date}*\n`;
            groupedTransactions[date].forEach(transaction => {
              const sign = transaction.transaction_type === 1 ? '+' : '-';
              output += `${transaction.id} ${transaction.name} (${sign}${transaction.amount})\n`;
            });
            output += '\n';
          }
          msg.reply(output);
        } else {
          msg.reply("No Transactions Found");
        }
      }
    } else if (cmd.includes("removet")) {
      if (receipents == "8104553818") {
        const taskId = cmd
          .substring(cmd.indexOf("removet") + "removet".length)
          .trim();
        if (!taskId) {
          msg.reply(
            "Please enter the transaction id you wish to delete.\nYou can check the transaction id using\n\n*tlist*"
          );
          return;
        }
        const tResult = await getTransaction(taskId);
        const result = await deleteTransaction(taskId);

        if (result.affectedRows > 0) {
          const ledgerId = tResult[0].ledger_id;
          const ledger = await getLedger(ledgerId);
          const variableValue = tResult[0].transaction_type;
          
          let amount = tResult[0].amount;
          let amount2 = ledger[0].amount;

          if (variableValue == 1)
            amount2 += amount
          else amount2 -= amount
          if (ledger.length) {
            const data2 = {
              id: ledgerId,
              name: ledger[0].name,
              amount: amount2
            }
            const result2 = await insertUpdateLedger(data2);
            if (result2.affectedRows > 0) {
              msg.reply("Transaction Deleted Successfully")
            }
          }
        } else {
          msg.reply("Error occured in deleting");
        }
      }
    }
    else {
      const employee = await getEmployee(receipents);
      if (employee.length) {
        const commands = [
          "create",
          "tasks",
          "done",
          "revert",
          "completed",
          "delete",
          "help",
          "elist",
          "etasks",
          "ecompleted",
          "report",
          "cledger",
          "ledgers",
          "dledger",
          "transact",
          "tlist",
          "removet"
        ];
        function findClosestCommand(userCommand) {
          // Convert user input to lowercase for case-insensitive matching
          const userInputLower = userCommand.toLowerCase();

          // Initialize variables to store closest match and minimum edit distance
          let closestMatch = "";
          let minDistance = Number.MAX_SAFE_INTEGER;

          // Loop through each predefined command
          for (const command of commands) {
            // Calculate Levenshtein distance between user input and predefined command
            const distance = levenshtein(userInputLower, command);

            // Update closest match if distance is smaller than current minimum distance
            if (distance < minDistance) {
              closestMatch = command;
              minDistance = distance;
            }
          }

          return closestMatch;
        }
        function levenshtein(s1, s2) {
          const len1 = s1.length;
          const len2 = s2.length;
          const matrix = [];

          // Initialize matrix
          for (let i = 0; i <= len1; i++) {
            matrix[i] = [i];
          }
          for (let j = 0; j <= len2; j++) {
            matrix[0][j] = j;
          }

          // Calculate Levenshtein distance
          for (let i = 1; i <= len1; i++) {
            for (let j = 1; j <= len2; j++) {
              const cost = s1[i - 1] === s2[j - 1] ? 0 : 1;
              matrix[i][j] = Math.min(
                matrix[i - 1][j] + 1,
                matrix[i][j - 1] + 1,
                matrix[i - 1][j - 1] + cost
              );
            }
          }

          return matrix[len1][len2];
        }
        const closestCommand = findClosestCommand(cmd);
        msg.reply(
          `Did you mean?\n*${closestCommand}* \n\nTry *help* for list of all the commands`
        );
      }
    }
  } catch (e) {
    console.log("Error forwarding API ", e);
  }
}

});
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

image

@MohammedMukarramMenn MohammedMukarramMenn added the bug Something isn't working label Jun 6, 2024
@theshubhampanchal
Copy link

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.

@pawankray
Copy link

This problem only occurs with Indian WhatsApp numbers.
Is your server located in India?

@MohammedMukarramMenn
Copy link
Author

server is not located in India, but the numbers are Indians.

@theshubhampanchal
Copy link

Yes, my server is located in India, and the number is also Indian.

@theshubhampanchal
Copy link

Tried this but not work :

  1. Updated WhatsApp in my Mobile device
  2. Use another mobile number.
  3. Delete ".wwebjs_auth" dir
  4. Delete ".wwebjs_auth" dir and use different number
  5. Using different server in case IP was banned of previous server (Worked for 1 day then again stopped)
  6. Create session in local system (windows) it's working In local system then decided to upload the ".wwebjs_auth" dir to new server. It was working on the server but only for a few hours.

@Hasnen-mr
Copy link

Deploy server in Banglore region and Nodejs 18.15.0 works for me.

@alechkos alechkos closed this as completed Jun 6, 2024
@alechkos
Copy link
Collaborator

alechkos commented Jun 7, 2024

Repository owner locked and limited conversation to collaborators Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants