whatsapp-api icon indicating copy to clipboard operation
whatsapp-api copied to clipboard

When I scan Qr code it successfully scanned. in mobile it show connected (Active) but when i hit status check api it gave session_not connected status

Open hetsalk opened this issue 1 year ago • 18 comments

When I scan Qr code it successfully scanned. in mobile it show connected (Active) but when i hit status check api it gave session_not connected status. So please guide me.

It gave Below error in terminal that

Initialize error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default') at puppeteer_evaluation_script:5:95

hetsalk avatar Apr 03 '24 11:04 hetsalk

I'm experiencing the same issue

alvarolucasno avatar Apr 03 '24 13:04 alvarolucasno

getting the same error

tiagopierredev avatar Apr 03 '24 21:04 tiagopierredev

same issue here

andrew-belyi avatar Apr 04 '24 11:04 andrew-belyi

Unfortunately it's issue by whatsapp web js and if you wanted to use this, you need to update the source. need to update the web cache + use whatsapp web js (webpack-exodus branch) inside package.js

update package.js

{
  "name": "whatsapp-web-api",
  "version": "1.0.0",
  "description": "REST API wrapper for whatsapp-web.js",
  "main": "server.js",
  "scripts": {
    "start": "node server.js",
    "test": "jest --runInBand",
    "swagger": "node swagger.js"
  },
  "dependencies": {
    "axios": "^1.6.5",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "express-rate-limit": "^6.11.2",
    "qr-image": "^3.2.0",
    "qrcode-terminal": "^0.12.0",
    "swagger-ui-express": "^4.6.3",
    "whatsapp-web.js": "pedroslopez/whatsapp-web.js#webpack-exodus"
  },
  "devDependencies": {
    "eslint": "^8.38.0",
    "eslint-config-standard": "^17.0.0",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-n": "^15.7.0",
    "eslint-plugin-promise": "^6.1.1",
    "jest": "^29.5.0",
    "supertest": "^6.3.3",
    "swagger-autogen": "^2.23.7"
  },
  "keywords": [
    "whatsapp",
    "whatsapp-web",
    "api",
    "wrapper",
    "rest",
    "express",
    "axios"
  ],
  "author": "Christophe Hubert",
  "license": "MIT",
  "engines": {
    "node": ">=14.17.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/chrishubert/whatsapp-web-api.git"
  },
  "bugs": {
    "url": "https://github.com/chrishubert/whatsapp-web-api/issues"
  },
  "homepage": "https://github.com/chrishubert/whatsapp-web-api",
  "private": true
}

inside docker-compose.yaml

from

  app:
    container_name: whatsapp_web_api
    image: chrishubert/whatsapp-web-api:latest # Pull the image from Docker Hub

to

  app:
    container_name: whatsapp_web_api
    build:
      context: . #do
      dockerfile: Dockerfile 

and the environment add

    environment:
      - WEB_VERSION_CACHE_TYPE=REMOTE
      - WEB_VERSION=2.3000.1012536975-alpha

Dockerfile change to

# Use the official Node.js Alpine image as the base image
FROM node:20-alpine

# Set the working directory
WORKDIR /usr/src/app

# Install Chromium and Git
ENV CHROME_BIN="/usr/bin/chromium-browser" \
    PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true" \
    NODE_ENV="production"

RUN set -x \
    && apk update \
    && apk upgrade \
    && apk add --no-cache \
       udev \
       ttf-freefont \
       chromium \
       git

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install the dependencies
RUN npm install --only=production

# Copy the rest of the source code to the working directory
COPY . .

# Expose the port the API will run on
EXPOSE 3000

# Start the API
CMD ["npm", "start"]

later just docker compose up will do.

ubeyou avatar Apr 04 '24 11:04 ubeyou

I managed to resolve here #190

arktnld avatar Apr 04 '24 12:04 arktnld

this temp solution is working I did:

  • updated package,json to pedroslopez/whatsapp-web.js#webpack-exodus
  • changed variables WEB_VERSION_CACHE_TYPE=REMOTE, WEB_VERSION=2.3000.1012536975-alpha

Im running not via docker, but using npm run start command

Thanks!

andrew-belyi avatar Apr 04 '24 13:04 andrew-belyi

Hello ,How Can Deploy this Code in Vps Server ?

proahmed22 avatar Apr 07 '24 07:04 proahmed22

This work for me, for windows 10 and im running not via docker and still using npm run start

WEB_VERSION_CACHE_TYPE=local

npm uninstall whatsapp-web.js npm install github:pedroslopez/whatsapp-web.js#webpack-exodus

rizkyjs avatar Apr 08 '24 10:04 rizkyjs

Please use the latest docker version 🙏

chrishubert avatar Apr 10 '24 06:04 chrishubert

Even after doing all the tips shown here, I'm unable to connect the number. Callback shows:

{"dataType":"loading_screen","data":{"percent":100,"message":"WhatsApp"},"sessionId":"1"} {"dataType":"loading_screen","data":{"percent":0,"message":"WhatsApp"},"sessionId":"1"} {"dataType":"loading_screen","data":{"percent":0,"message":"WhatsApp"},"sessionId":"1"} {"dataType":"loading_screen","data":{"percent":0,"message":"WhatsApp"},"sessionId":"1"} {"dataType":"loading_screen","data":{"percent":72,"message":"WhatsApp"},"sessionId":"1"} {"dataType":"loading_screen","data":{"percent":95,"message":"WhatsApp"},"sessionId":"1"} {"dataType":"loading_screen","data":{"percent":99,"message":"WhatsApp"},"sessionId":"1"}

node -v

v21.7.3

npm -v

10.5.0

npm uninstall whatsapp-web.js

npm install github:pedroslopez/whatsapp-web.js#webpack-exodus

npm WARN deprecated [email protected]: < 21.8.0 is no longer supported

npm run start

[email protected] start node server.js

(node:1123768) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. at node:punycode:3:9 at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:398:7) at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:337:10) at loadBuiltinModule (node:internal/modules/helpers:104:7) at Module._load (node:internal/modules/cjs/loader:999:17) at Module.require (node:internal/modules/cjs/loader:1230:19) at require (node:internal/modules/helpers:179:18) at Object. (/home/rafael/whatsapp-api/node_modules/whatwg-url/lib/url-state-machine.js:2:18) at Module._compile (node:internal/modules/cjs/loader:1368:14) at Module._extensions..js (node:internal/modules/cjs/loader:1426:10) Server running on port 3000

I've noticed that when installing github:pedroslopez/whatsapp-web.js#webpack-exodus, npm tries to install an old puppeter version (18.2.1), which seems not being supported anymore. May this be the trick? How to fix it?

Please help.

Thanks

raffus avatar Apr 18 '24 18:04 raffus

getting the same error

Roei639 avatar Apr 20 '24 09:04 Roei639

no update yet :(

mdestafadilah avatar Apr 24 '24 08:04 mdestafadilah

this temp solution is working I did:

  • updated package,json to pedroslopez/whatsapp-web.js#webpack-exodus
  • changed variables WEB_VERSION_CACHE_TYPE=REMOTE, WEB_VERSION=2.3000.1012536975-alpha

Im running not via docker, but using npm run start command

Thanks!

still not working, always ssession_not_connected

mdestafadilah avatar Apr 26 '24 04:04 mdestafadilah

Please use the latest docker version 🙏

After update with latest version after connected and i check sessions return

{
  "success": false,
  "state": null,
  "message": "browser tab closed"
}

any update?

arislanhaikal avatar May 01 '24 08:05 arislanhaikal

2.3000.1012536975-alpha

I am solved with change docker env

- RATE_LIMIT_MAX=1000
- RATE_LIMIT_WINDOW_MS=1000
- WEB_VERSION='2.3000.1012536975-alpha'
- WEB_VERSION_CACHE_TYPE=remote
- RECOVER_SESSIONS=TRUE

arislanhaikal avatar May 01 '24 09:05 arislanhaikal

2.3000.1012536975-alpha

I am solved with change docker env

  • RATE_LIMIT_MAX=1000
  • RATE_LIMIT_WINDOW_MS=1000
  • WEB_VERSION='2.3000.1012536975-alpha'
  • WEB_VERSION_CACHE_TYPE=remote
  • RECOVER_SESSIONS=TRUE

working with non-docker package!! thanks!!

mdestafadilah avatar May 02 '24 02:05 mdestafadilah

Is the problem found?

Roei639 avatar May 23 '24 10:05 Roei639

Is the problem found?

not sure, but i success with trick like here https://github.com/chrishubert/whatsapp-api/issues/189#issuecomment-2089405230

mdestafadilah avatar May 23 '24 14:05 mdestafadilah