whatsapp-web.js: the qrcode does not come out, it is always pending.

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

the qrcode does not come out, it is always pending. i tried to reset the sessions and also to update the chrome browser. Anyone have the same problem?

image error: https://prnt.sc/T89Qu8GE5Kv4

Expected behavior

i expect the qrcode to be returned

Steps to Reproduce the Bug or Issue

app.get('/:instance/status', async (req, res) => {

            var instance = req.params.instance;
            console.log("/" + colore.magenta(instance) + '/status');

            //    sendMessageAdmin(draw.path("/" + colore.magenta(instance) + "/status"));

            init_client(instance).then(
                function resolve(data) {
                    if (req.query.img && data["accountStatus"] == STATUS.GOT_QR_CODE) {
                        res.render('qr', data);
                    } else {
                        res.status(200).json(data);
                    }
                },
                function reject(data) {
                    res.status(200).json(data);
                }
            ).catch(
                function reject(data) {
                    res.status(200).json(data);
                }
            );

        });

Relevant Code

No response

Browser Type

Google Chrome

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Linux Phone OS: iOS whatsapp-web.js 1.18.2 Node.js : v16.15.1

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 22 (8 by maintainers)

Most upvoted comments

@stefanfuchs Thank you for the prompt response, its works pretty well for me too

I’m actually saving to a .tar.gz file. Some code below for reference:

import * as tar from 'tar'

  protected async saveSessionToZip(): Promise<boolean> {
    const zipPath = this.getSessionZipDataPath()
    const sessionDataPathParent = this.getSessionDataPathParentDir()
    const sessionDirName = this.getSessionDirName()

    try {
      await tar.c({ file: zipPath, cwd: sessionDataPathParent }, [sessionDirName])
    } catch (e) {
      console.log(`[WhatsappWebServer.restoreSessionFromZip] error while saving zip file: `, e)
      return false
    }

    return true
  }

  protected async restoreSessionFromZip(): Promise<boolean> {
    const zipPath = this.getSessionZipDataPath()
    const zipExists = await this.sessionZipExists()
    if (!zipExists) {
      console.log(`[WhatsappWebServer.restoreSessionFromZip] session zip file do not exists. Not restoring session`)
      return false
    }

    const sessionDataPathParentDir = this.getSessionDataPathParentDir()
    const hasPermissionInDir = await this.checkSessionDirPermission(sessionDataPathParentDir)
    if (!hasPermissionInDir) {
      console.log(`[WhatsappWebServer.restoreSessionFromZip] no permission in sesion dir. Not restoring session`)
      return false
    }

    // delete previous session dir
    await this.clearSession()

    try {
      await tar.x({
        file: zipPath,
        C: sessionDataPathParentDir,
      })
    } catch (e) {
      console.log(`[WhatsappWebServer.restoreSessionFromZip] error while extracting zip file: `, e)
      return false
    }

    console.log(`[WhatsappWebServer.restoreSessionFromZip] restored session from zip file: `, zipPath)
    return true
  }
  • zipPath is the path in amazon EFS where the zip file is saved.
  • sessionDataPathParentDir and sessionDirName are the path to the directory where whatsapp-web.js saves the session files (locally).

@massimorm did you find any solution for making it work on EFS? I can’t figure out why it doesn’t work. Using EBS is not an option for me. Right now I can only make whatsapp work by using NoAuth mode (no saving on disk).

unfortunately not, i had to move everything to ebs and use a disk share. I too would like to go back to EFS