open-wa / wa-automate-docker

💬 🤖 The easiest way to turn your WhatsApp into an API. Be sure to 🌟 this repository for updates!
106 stars 31 forks source link

How to save login session ? #34

Closed fire17 closed 2 years ago

fire17 commented 2 years ago

Hi there, really liking this docker version , its much faster then the python selenium im used too was also able to get the webhooks working and will now start to filter the events

the only thing that i still havnt been able to do is to save the session so i do not need to scan and the qr and login everytime

would love it if you could advise on how this is done thank you very much :) have a good one!

fire17 commented 2 years ago

do i need to setup volumes for this ? help will be very appreciated :pray:

smashah commented 2 years ago

What are you trying right now? Is your host account using MD?

fire17 commented 2 years ago

What are you trying right now? Is your host account using MD?

@smashah sry what is MD ? I'm having issues with the python version and trying out the docker which seems cool but i cant understand how to not scan everytime ...

smashah commented 2 years ago

MD = multi device mode.

Add --multi-device flag to the end of the docker run command. Keep the session running for a few minutes, send some messages back and forth then restart the container

fire17 commented 2 years ago

ok , is that the official way to save the session ?

i assumed multi-devvice is only used if i applied to the whatsapp beta

I'll try with --multi-device do i need to apply to the wa beta for this ? is there a way to safely exit the docker?

if i understand you correct , just adding --multi-device , some interactions and time , and it will save my login

fire17 commented 2 years ago

Got an error when running with --multi-device

- Launch inject: 293ms
- WAPI Reinjected
- Checking if session is valid
- Launch inject: 477ms
- The session is invalid. Retrying
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn ps ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn ps',
  path: 'ps',
  spawnargs: [ '-A', '-o', 'ppid,pid,stat,comm' ]
}
- Launch inject: 293ms
- WAPI Reinjected
- Checking if session is valid
- Launch inject: 477ms
- The session is invalid. Retrying
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn ps ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn ps',
  path: 'ps',
  spawnargs: [ '-A', '-o', 'ppid,pid,stat,comm' ]
}

Node.js v17.6.0

this happens regardless if my phone uses multi-device beta I'll try with different node version maybe ill change something ... please let me know what you recommend :pray: @smashah

fire17 commented 2 years ago

getting errors with --multi-device

Can i still just wait 5 mins or so and get the session save automatically (in normal mode) ? Do i need to change the command afterwards? docker run -p 8080:8080 --init openwa/wa-automate:latest --license-key ....... How is the session data saved on the docker ? dont i have to setup volumes or something for that ? thx :pray:

EDIT : i ran the normal session , and exited the docker (with ^C) , when running again i'm asked for QR maybe i need to stop it with docker stop ? or commit before closing ? thx :)

fire17 commented 2 years ago

FINALLY ! managed to save my login :) i understood it's not the best practice to use docker commit, if you can explain to me a different way to save login ill be very happy to hear (If not this issue can be closed)

i did (in another terminal)

# checking for current running container id
docker ps
# save current as wa image
docker commit 2a1fe72c441f wa
# stop the current container
docker stop 2a1fe72c441f

#And Finally:
docker run -p 8080:8080 --init wa --license-key ......

which loaded my whatsapp session without re-scanning the QR :smile: :heart: :rocket:

smashah commented 2 years ago

Glad you figured it out. TBH i am very busy on the main library nowadays

willmaraujo commented 2 years ago

Hi, have you managed to fix it? I'm facing the same issue.

Theblood commented 1 year ago

This should be in the readme.md , it is very important.