question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QR code scanning problem with the api scan

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When I am scanning the generated qr code provided by whatsapp.web.js i am not able to login to the server. It shows following error:

Invalid QR code Make sure you’re scanning a QR code displayed on WhatsApp app. If it continues to not work, update the app or refresh the page and try again

Expected behavior

As a user, I expected to login when I scan the qr code with code scanner in whatsapp mobile applicaiton

Steps to Reproduce the Bug or Issue

  1. Initiate the whatsapp client like this:
const { Client, MessageMedia, LocalAuth } = require("whatsapp-web.js");
const whatsapp_client = new Client({
    qrTimeoutMs: 0,
    puppeteer: {
        headless: false,
        args: [
            "--no-sandbox",
            "--disable-setuid-sandbox",
            "--unhandled-rejections=strict",
            "--disable-dev-shm-usage",
            "--fast-start",
        ]
    },
    // session: sessionCfg,
    authStrategy: new LocalAuth({
        clientId: "uniqid"
    })
});
  1. Send the qr code to frontend Here i am using socket.io to communicate with frontend
whatsapp_client.on("qr", qr => {
    socket.emit("qr", qr);
});
  1. Generate QR code with any frontend library. Here i am using qrcode.js in javascript I also tried using phpqrcode/qrlib.php to generate barcode but still getting same problem 😦
  2. Scan the QR code in whatsapp mobile application

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Ubuntu 20 Phone OS: Android 8.1.0 whatsapp-web.js version: 1.16.6 WhatsApp Web version: 2.2218.8 Node.js Version v16.4.2

Additional context

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
sarifulcommented, May 31, 2022

So the issue was when generating qrcode using php-qrlib or js qrcode (frontend), whatsapp is not recognising the code. Thanks @Yuri-Lima for sharing the solution

0reactions
Olinaricommented, Dec 3, 2022

same here, only happens when deployed to vercel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

9 reasons Why Your QR Code is Not Working - Beaconstac blog
If the QR Code is still not working, try scanning it via an external QR Code scanner or update your operating system to...
Read more >
Common QR Code Scanning Problems and How to Fix Them
Is your QR Code not working? Here is an overview on common QR Code scanning problems and how to solve them in this...
Read more >
Build a Web QR Code Scanner using the Barcode Detection API
The article talks about how to build a web QR code scanner using ... The API aims at detecting features like faces and...
Read more >
6 reasons why your QR code is not working - QRCode Monkey
Avoid breaking your QR code by being aware of a few things. Here are 6 things that can cause trouble when scanning your...
Read more >
Trying to scan a QR Code then call an API - Stack Overflow
I am trying to create a mobile app where the user will scan a unique QR code, the program should then ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found