Giter Club home page Giter Club logo

Comments (32)

RaheesAhmed avatar RaheesAhmed commented on June 20, 2024 9

Fixed #3073

You have to pass local Auth
you can try it like this

npm install whatsapp-web.js

npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

from whatsapp-web.js.

ornsteindss avatar ornsteindss commented on June 20, 2024 2

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34
        const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
                                                                    ^

TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

from whatsapp-web.js.

daoudibaby avatar daoudibaby commented on June 20, 2024 2

Fixed #3073
You have to pass local Auth you can try it like this
npm install whatsapp-web.js
npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

it worked thanks

from whatsapp-web.js.

indrafani03 avatar indrafani03 commented on June 20, 2024 1

#3075 (comment)

what is the mean 1.23.-1 alpha?

change the whatsapp-web.js to "^1.23.1-alpha.6" on your package.json

from whatsapp-web.js.

jorge281 avatar jorge281 commented on June 20, 2024

I have the same problem

from whatsapp-web.js.

sauqi28 avatar sauqi28 commented on June 20, 2024

yes i have same problem

from whatsapp-web.js.

FehRodriguesHubner avatar FehRodriguesHubner commented on June 20, 2024

If you are running linux, try to create a new user and run the code as the new user.
Worked for me.

from whatsapp-web.js.

Ayperoz avatar Ayperoz commented on June 20, 2024

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34
        const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
                                                                    ^

TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

I have the same problem running on Windows or Ubuntu Server.
multidevice
chromium

from whatsapp-web.js.

sauqi28 avatar sauqi28 commented on June 20, 2024

3 Jun 15:07:00 - [info] [whatsappLink:Web] Status : Connecting to Whatsapp...
3 Jun 15:07:02 - [info] [whatsappLink:Web] Status : Connecting to Whatsapp...
3 Jun 15:07:03 - [red] Uncaught Exception:
3 Jun 15:07:03 - [error] Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
at puppeteer_evaluation_script:5:95
at ExecutionContext._evaluateInternal (/root/.node-red/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecutionContext.evaluate (/root/.node-red/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
at async Client.initialize (/root/.node-red/node_modules/whatsapp-web.js/src/Client.js:323:9)

from whatsapp-web.js.

FehRodriguesHubner avatar FehRodriguesHubner commented on June 20, 2024

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34
        const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
                                                                    ^

TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

Try adding this to you config object when initializing new Client:

        clientObj.webVersionCache = {
            type: 'remote',
            remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html',
        }
      const client = new Client(clientObj);

from whatsapp-web.js.

daoudibaby avatar daoudibaby commented on June 20, 2024

it give me now:
` clientObj.webVersionCache = {
^

ReferenceError: clientObj is not defined`
can you send me a docker of your working version so i can use it ?
my email: [email protected]

from whatsapp-web.js.

Hambaini avatar Hambaini commented on June 20, 2024

i have same problem. could you please help me ?

from whatsapp-web.js.

indrafani03 avatar indrafani03 commented on June 20, 2024

#3075 (comment)

from whatsapp-web.js.

Hambaini avatar Hambaini commented on June 20, 2024

#3075 (comment)

what is the mean 1.23.-1 alpha?

from whatsapp-web.js.

Hambaini avatar Hambaini commented on June 20, 2024

#3075 (comment)

what is the mean 1.23.-1 alpha?

change the whatsapp-web.js to "^1.23.1-alpha.6" on your package.json

oo i see.ok fix it with ur comment. thx all

from whatsapp-web.js.

sauqi28 avatar sauqi28 commented on June 20, 2024

Fixed #3073

You have to pass local Auth you can try it like this

npm install whatsapp-web.js

npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

from whatsapp-web.js.

RaheesAhmed avatar RaheesAhmed commented on June 20, 2024

Fixed #3073
You have to pass local Auth you can try it like this
npm install whatsapp-web.js
npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

from whatsapp-web.js.

sauqi28 avatar sauqi28 commented on June 20, 2024

Fixed #3073
You have to pass local Auth you can try it like this
npm install whatsapp-web.js
npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

root@ed9133fc9883:~/.node-red/node_modules# node-red
4 Jun 04:02:51 - [info]

Welcome to Node-RED

4 Jun 04:02:51 - [info] Node-RED version: v3.1.9
4 Jun 04:02:51 - [info] Node.js version: v22.1.0
4 Jun 04:02:51 - [info] Linux 6.5.0-35-generic x64 LE
(node:25350) [DEP0059] DeprecationWarning: The util.log API is deprecated. Please use console.log() with a custom formatter or a third-party logger instead. (Use node --trace-deprecation ...to show where the warning was created) 4 Jun 04:02:51 - [info] Loading palette nodes (node:25350) [DEP0040] DeprecationWarning: Thepunycode` module is deprecated. Please use a userland alternative instead.
4 Jun 04:02:51 - [info] Settings file : /root/.node-red/settings.js
4 Jun 04:02:51 - [info] Context store : 'default' [module=memory]
4 Jun 04:02:51 - [info] User directory : /root/.node-red
4 Jun 04:02:51 - [warn] Projects disabled : editorTheme.projects.enabled=false
4 Jun 04:02:51 - [info] Flows file : /root/.node-red/flows.json
4 Jun 04:02:51 - [info] Server now running at http://127.0.0.1:1880/
4 Jun 04:02:51 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

4 Jun 04:02:51 - [info] Starting flows
4 Jun 04:02:51 - [info] [whatsappLink:Web] Status : Initializing Whatsapp..
4 Jun 04:02:51 - [warn] [telegram bot:5c5852f85c2d8eb3] Aborting: Token of Antares28_bot is not set
4 Jun 04:02:51 - [info] [whatsappLink:Web] Status : Initializing Whatsapp..
4 Jun 04:02:52 - [warn] [telegram sender:31d12aa54f4fd5a4] bot not initialized.
4 Jun 04:02:52 - [info] Started flows
(node:25350) [DEP0044] DeprecationWarning: The util.isArray API is deprecated. Please use Array.isArray() instead.
4 Jun 04:02:52 - [error] [chats-out:Chats Out] TypeError: Cannot read properties of undefined (reading 'remoteJid')
4 Jun 04:02:53 - [red] Uncaught Exception:
4 Jun 04:02:53 - [error] TypeError: Cannot read properties of null (reading '1')
at LocalWebCache.persist (/root/.node-red/node_modules/node-red-contrib-whatsapp-link/node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
at /root/.node-red/node_modules/node-red-contrib-whatsapp-link/node_modules/whatsapp-web.js/src/Client.js:744:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
root@ed9133fc9883:~/.node-red/node_modules#

from whatsapp-web.js.

fbtx2024 avatar fbtx2024 commented on June 20, 2024

I have the same problem and the solutions provided here have not worked for me, does anyone have any other suggestions?

the error is:

C:\Users\Gateway\Documents\APM MENSAJE\programas\prospectador> node prospectador.js

C:\Users\Gateway\Documents\APM MENSAJE\programas\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34
const version = indexHtml.match(/manifest-([\d\.]+).json/)[1];
^

TypeError: Cannot read properties of null (reading '1')
at LocalWebCache.persist (C:\Users\Gateway\Documents\APM MENSAJE\programas\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69)
at C:\Users\Gateway\Documents\APM MENSAJE\programas\node_modules\whatsapp-web.js\src\Client.js:744:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

tanks

from whatsapp-web.js.

ornsteindss avatar ornsteindss commented on June 20, 2024

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34
        const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
                                                                    ^

TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

Try adding this to you config object when initializing new Client:

        clientObj.webVersionCache = {
            type: 'remote',
            remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html',
        }
      const client = new Client(clientObj);

it worked, thanks

from whatsapp-web.js.

hsxonz avatar hsxonz commented on June 20, 2024

3 Jun 15:07:00 - [info] [whatsappLink:Web] Status : Connecting to Whatsapp... 3 Jun 15:07:02 - [info] [whatsappLink:Web] Status : Connecting to Whatsapp... 3 Jun 15:07:03 - [red] Uncaught Exception: 3 Jun 15:07:03 - [error] Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default') at puppeteer_evaluation_script:5:95 at ExecutionContext._evaluateInternal (/root/.node-red/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async ExecutionContext.evaluate (/root/.node-red/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16) at async Client.initialize (/root/.node-red/node_modules/whatsapp-web.js/src/Client.js:323:9)

Hello your happen have a resolve for this

from whatsapp-web.js.

crocodile2024 avatar crocodile2024 commented on June 20, 2024

Fixed #3073
You have to pass local Auth you can try it like this
npm install whatsapp-web.js
npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

Hi,
that worked not for me. Now I have the following error:

Error initializing client TimeoutError: Waiting for selector [data-icon='search']failed: Waiting failed: 60000ms exceeded at Timeout.<anonymous> (/home/pi/wwebjs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:64:32) at listOnTimeout (node:internal/timers:569:17) at process.processTimers (node:internal/timers:512:7)

from whatsapp-web.js.

daoudibaby avatar daoudibaby commented on June 20, 2024

Fixed #3073
You have to pass local Auth you can try it like this
npm install whatsapp-web.js
npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

can you check your email i sent you an email to talk

from whatsapp-web.js.

RaheesAhmed avatar RaheesAhmed commented on June 20, 2024

Fixed #3073
You have to pass local Auth you can try it like this
npm install whatsapp-web.js
npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

can you check your email i sent you an email to talk

I didint received it you can also check i have working example here it is linked with openai assistant

https://github.com/RaheesAhmed/openai-assistant-with-whatsapp-web

from whatsapp-web.js.

crocodile2024 avatar crocodile2024 commented on June 20, 2024

Hello,
I copied the Code for the wweb-js library but I have the same error. What can I do? My Version of the Library is
^1.23.0 In package.js.

Do I Need another version?

from whatsapp-web.js.

julianosaless avatar julianosaless commented on June 20, 2024

Hi guys, do you know why whatsapp-web is so unstable, all the time just stopping to work?

from whatsapp-web.js.

thiagosiebert avatar thiagosiebert commented on June 20, 2024

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34
        const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
                                                                    ^

TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

Try adding this to you config object when initializing new Client:

        clientObj.webVersionCache = {
            type: 'remote',
            remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html',
        }
      const client = new Client(clientObj);

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34
        const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
                                                                    ^

TypeError: Cannot read properties of null (reading '1')
    at LocalWebCache.persist .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

Try adding this to you config object when initializing new Client:

        clientObj.webVersionCache = {
            type: 'remote',
            remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html',
        }
      const client = new Client(clientObj);

In which file do I make this change?

from whatsapp-web.js.

DanielPerMon avatar DanielPerMon commented on June 20, 2024

Hi everyone, I'm having an issue with the 'authenticated' event, I can scan QR but then nothing happens, not any logs or errors form any package, below is the object I am using in my script

new Client({
puppeteer: {args: ['--no-sandbox', '--disable-setuid-sandbox'],headless: true},
authStrategy: new LocalAuth(),
webVersionCache: {type: 'remote',
remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html'}})

Wonder if a version is working fine

from whatsapp-web.js.

silveira2974 avatar silveira2974 commented on June 20, 2024

Credits for @BenyFilho from Discord.

Using version Exodus WhatsApp Web 2.30xx:
1- npm install github:pedroslopez/whatsapp-web.js#webpack-exodus;
2- if you are using, remove WebCache;
3- delete folder node_modules and wwebjs_auth;
4- npm install;
5- start your script.

Using version WhatsApp Web 2.24xx:
1- npm i [email protected];
2- Use WebCache;

{
  webVersion: "2.2412.54",
  webVersionCache: {
        type: "remote",
        remotePath:
          "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
      },
}

3- delete folder node_modules and wwebjs_auth;
4- npm install;
5- start your script.

from whatsapp-web.js.

thiagosiebert avatar thiagosiebert commented on June 20, 2024

Credits for @BenyFilho from Discord.

Using version Exodus WhatsApp Web 2.30xx: 1- npm install github:pedroslopez/whatsapp-web.js#webpack-exodus; 2- if you are using, remove WebCache; 3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.

Using version WhatsApp Web 2.24xx: 1- npm i [email protected]; 2- Use WebCache;

{
  webVersion: "2.2412.54",
  webVersionCache: {
        type: "remote",
        remotePath:
          "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
      },
}

3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.

How do I remove WebCache or in which file should I pass the type: "remote" information?

from whatsapp-web.js.

silveira2974 avatar silveira2974 commented on June 20, 2024

Credits for @BenyFilho from Discord.
Using version Exodus WhatsApp Web 2.30xx: 1- npm install github:pedroslopez/whatsapp-web.js#webpack-exodus; 2- if you are using, remove WebCache; 3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.
Using version WhatsApp Web 2.24xx: 1- npm i [email protected]; 2- Use WebCache;

{
  webVersion: "2.2412.54",
  webVersionCache: {
        type: "remote",
        remotePath:
          "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
      },
}

3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.

How do I remove WebCache or in which file should I pass the type: "remote" information?

You don't need pass it, just initialize the client normally.

Example:

const client = new Client({ authStrategy: new LocalAuth(), puppeteer: { headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--single-process', '--no-zygote', '--no-first-run', '--no-default-browser-check', '--disable-extensions', '--disable-default-apps', '--disable-sync', '--disable-translate', '--disable-web-security', '--disable-features=site-per-process', '--disable-infobars', '--window-position=0,0', '--ignore-certificate-errors', '--ignore-certificate-errors-spki-list', '--disable-gpu', '--disable-webgl', '--disable-threaded-animation', '--disable-threaded-scrolling', '--disable-in-process-stack-traces', '--disable-histogram-customizer', '--disable-gl-extensions', '--disable-composited-antialiasing', '--disable-canvas-aa', '--disable-3d-apis', '--disable-accelerated-2d-canvas', '--disable-accelerated-jpeg-decoding', '--disable-accelerated-mjpeg-decode', '--disable-app-list-dismiss-on-blur', '--disable-accelerated-video-decode' ] } });

from whatsapp-web.js.

alechkos avatar alechkos commented on June 20, 2024

#1621

from whatsapp-web.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.