devlikeapro / waha

WAHA - WhatsApp HTTP API (REST API) that you can configure in a click!
https://waha.devlike.pro/
Apache License 2.0
808 stars 248 forks source link

Session would not be saved if server down or docker stop suddenly #160

Open felixnguyen258 opened 10 months ago

felixnguyen258 commented 10 months ago

Hi

I face to an issue like the step procedure as below:

1) Create and start new sessions named "session_test_01" and "session_test_02". OK

image

2) Scan QR Code to link WA account with WAHA app. OK

image

3) Stop docker - re-run docker.

image

Cannot query previous session.

image

Workaround: I tried to hard-code the configuration with <_-e "WHATSAPP_START_SESSION=session_test_01, session_test02"> in docker run command and it will add 2 sessions but the status is "SCAN_QR_CODE".

image

Any advice for auto saving and auto init the previous session name list after instances down?

Thanks & Regards, Felix

allburov commented 10 months ago

Hi!

Any advice for auto saving

Could you share the command you run docker container with?

It should container -vpwd/.sessions:/app/.sessions. If it doesn't work - please replace pwd with the real path, like this way - -v /home/allburov/.sessions:/app/.sessions

docker run --rm -d -v /home/allburov/.sessions:/app/.sessions -p 3000:3000/tcp --name whatsapp-http-api devlikeapro/whatsapp-http-api-plus

Any advice for ... auto init the previous session name list after instances down

You can set WHATSAPP_RESTART_ALL_SESSIONS=True environment variable - on the container start it'll restart all STOPPED session. It can't actually track which session was running so it'll restart all sessions - you can see the list by using GET /api/sessions/all=True. If you don't want STOPPED session to be restart - you can logout it with POST /api/sessions/logout

Let me know if it helps!

devlikepro commented 1 month ago

@felixnguyen258 Do you have any questions here or the suggestion helped?

patron:PRO