devlikeapro / waha

WAHA - WhatsApp HTTP API (REST API) that you can configure in a click! Two engines: chromium-based WEBJS and pure-websocket NOWEB
https://waha.devlike.pro/
Apache License 2.0
1k stars 304 forks source link

[BUG][NOWEWB] - NOWEB will remain in the STARTING state after automatic restart. It requires manual ReStart to change to WORKING. #586

Closed HuangDaHui closed 3 weeks ago

HuangDaHui commented 1 month ago

1728549469965 NOWEB will remain in the STARTING state after automatic restart. It requires manual ReStart to change to WORKING.

HuangDaHui commented 1 month ago

This is an accidental phenomenon. Normally, it will automatically change to WORKING after a few seconds of STARTING.

HuangDaHui commented 1 month ago

Also, I would like to ask if it is possible to turn off the automatic restart of noweb?

HuangDaHui commented 1 month ago

version 2024.10.1

HuangDaHui commented 1 month ago

image Suddenly a large batch changed to the failed state, and returned to normal after restarting.

devlikepro commented 1 month ago

I would like to ask if it is possible to turn off the automatic restart of noweb?

You need to remove WHATSAPP_RESTART_ALL_SESSIONS from the environemnt variables

patron:PRO

devlikepro commented 1 month ago

Normally, it will automatically change to WORKING after a few seconds of STARTING

yeah, noticed this behaviour after container restart too, checking it!

patron:PRO

devlikepro commented 1 month ago

Quick question - do you use file or mongodb?

We should start CRM system or something to avoid such question over an over :D

patron:PRO

HuangDaHui commented 1 month ago

Quick question - do you use file or mongodb?

We should start CRM system or something to avoid such question over an over :D

patron:PRO use mongodb

HuangDaHui commented 1 month ago

I would like to ask if it is possible to turn off the automatic restart of noweb?

You need to remove WHATSAPP_RESTART_ALL_SESSIONS from the environemnt variables

patron:PRO OK, thanks

devlikepro commented 1 month ago

Let's try 2024.10.5 and see if it helps :crossed_fingers:

patron:PRO

HuangDaHui commented 3 weeks ago

I would like to ask if it is possible to turn off the automatic restart of noweb?

You need to remove WHATSAPP_RESTART_ALL_SESSIONS from the environemnt variables

patron:PRO Hi,I deleted the WHATSAPP_RESTART_ALL_SESSIONS environment variable, will this have any impact on NOWEB? I think your design like this must be useful

HuangDaHui commented 3 weeks ago

Let's try 2024.10.5 and see if it helps 🤞

patron:PRO

image Doesn't seem to help, these sessions stay on starring

devlikepro commented 3 weeks ago

@HuangDaHui could you try to add WAHA_AUTO_START_DELAY_SECONDS=1 environment variable? The issue likely because all sessions starts at once (almost), but with 1 seconds delay it can help slowly run them one by one to avoid such issues.

If there's something in logs right after the start, it'd help us as well :pray:

patron:PRO

HuangDaHui commented 3 weeks ago

@HuangDaHui could you try to add WAHA_AUTO_START_DELAY_SECONDS=1 environment variable? The issue likely because all sessions starts at once (almost), but with 1 seconds delay it can help slowly run them one by one to avoid such issues.

If there's something in logs right after the start, it'd help us as well 🙏

patron:PRO

ok let me try I deleted the WHATSAPP_RESTART_ALL_SESSIONS environment variable, will this have any impact on NOWEB? I think your design like this must be useful

HuangDaHui commented 3 weeks ago

I would like to ask if it is possible to turn off the automatic restart of noweb?

You need to remove WHATSAPP_RESTART_ALL_SESSIONS from the environemnt variables

patron:PRO

image Deleting it seems to have no effect. It still turns into starting in large batches and cannot be started. I don’t know why?

HuangDaHui commented 3 weeks ago

Could it be related to MongoDB? I have another container with relatively few sessions, and this never seems to happen.

HuangDaHui commented 3 weeks ago

I would like to ask if it is possible to turn off the automatic restart of noweb?

You need to remove WHATSAPP_RESTART_ALL_SESSIONS from the environemnt variables patron:PRO

image Deleting it seems to have no effect. It still turns into starting in large batches and cannot be started. I don’t know why?

Soon after this happens, the container will exit on its own and I need to re-docker start id

devlikepro commented 3 weeks ago

@HuangDaHui Do you use a single MongoDB with multiple WAHA workers by any change? Lioke multiple docker container but with the same MONGO_URL string? If yes - you need to setup WAHA_WORKER_ID=waha{ID} for each container (unique one)

Could you try to add WAHA_WORKER_RESTART_SESSIONS=False - in this case after restart all sessions will be stopped

patron:PRO

HuangDaHui commented 3 weeks ago

@HuangDaHui Do you use a single MongoDB with multiple WAHA workers by any change? Lioke multiple docker container but with the same MONGO_URL string? If yes - you need to setup WAHA_WORKER_ID=waha{ID} for each container (unique one)

Could you try to add WAHA_WORKER_RESTART_SESSIONS=False - in this case after restart all sessions will be stopped

patron:PRO

Yes, 2 containers use the same MongoDB, 1 NOWEB and 1 WEBJS Is this the reason that causes the problem?

HuangDaHui commented 3 weeks ago

@HuangDaHui Do you use a single MongoDB with multiple WAHA workers by any change? Lioke multiple docker container but with the same MONGO_URL string? If yes - you need to setup WAHA_WORKER_ID=waha{ID} for each container (unique one)

Could you try to add WAHA_WORKER_RESTART_SESSIONS=False - in this case after restart all sessions will be stopped

patron:PRO

docker run -it -p 15101:3000/tcp --restart=always -e "WAHA_WORKER_ID=waha15101" -e "WHATSAPP_DEFAULT_ENGINE=NOWEB" -e WHATSAPP_SESSIONS_MONGO_URL=mongodb://192.168.18.170:27018/ -e WHATSAPP_FILES_LIFETIME=0 -e WHATSAPP_RESTART_ALL_SESSIONS=True -e WAHA_AUTO_START_DELAY_SECONDS=1 devlikeapro/waha-plus Is this okay?

HuangDaHui commented 3 weeks ago

No matter how I configure it, it always becomes starting and I don't know how to fix it image

devlikepro commented 3 weeks ago

WAHA_WORKER_RESTART_SESSIONS=False this one too After that after each restart you need to start them manually. But let's see if it helps at all

patron:PRO

devlikepro commented 3 weeks ago

Yes, 2 containers use the same MongoDB, 1 NOWEB and 1 WEBJS

That should be fine

patron:PRO

HuangDaHui commented 3 weeks ago

WAHA_WORKER_RESTART_SESSIONS=False这个也是 每次重启后你都需要手动启动它们。但让我们看看它是否有帮助

赞助人:PRO

ok let me try Is there anything else that could cause this problem to occur? It happens very frequently recently, which makes me very distressed

devlikepro commented 3 weeks ago

Is there anything else that could cause this problem to occur?

Logs would help to understand what is happening :pray:

patron:PRO

HuangDaHui commented 3 weeks ago

Is there anything else that could cause this problem to occur?

Logs would help to understand what is happening 🙏

patron:PRO

I don't know how to get useful logs. Can you tell me what command to execute to get them?

HuangDaHui commented 3 weeks ago
  throw er; // Unhandled 'error' event
  ^

Error: Opening handshake has timed out at ClientRequest. (/app/node_modules/@adiwajshing/baileys/node_modules/ws/lib/websocket.js:872:7) at ClientRequest.emit (node:events:520:28) at TLSSocket.emitRequestTimeout (node:_http_client:851:9) at Object.onceWrapper (node:events:634:28) at TLSSocket.emit (node:events:520:28) at Socket._onTimeout (node:net:590:8) at listOnTimeout (node:internal/timers:594:17) at process.processTimers (node:internal/timers:529:7) Emitted 'error' event on WebSocketClient instance at: at WebSocket. (/app/node_modules/@adiwajshing/baileys/lib/Socket/Client/web-socket-client.js:46:100) at WebSocket.emit (node:events:520:28) at emitErrorAndClose (/app/node_modules/@adiwajshing/baileys/node_modules/ws/lib/websocket.js:1035:13) at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

Is this useful?

devlikepro commented 3 weeks ago

You don't use any proxies for the sessions, right? Seen this before with bad proxies

patron:PRO

HuangDaHui commented 3 weeks ago

You don't use any proxies for the sessions, right? Seen this before with bad proxies

patron:PRO

No proxy used

HuangDaHui commented 3 weeks ago

Will it have any impact if I run 2 MongoDB containers in docker? They use different ports

HuangDaHui commented 3 weeks ago

The same is NOWEB, mongodb://192.168.18.170:27017. When using this MongoDB, everything is normal, but when using this MongoDB, it often gets stuck. mongodb://192.168.18.170:27018/

devlikepro commented 3 weeks ago

I run 2 MongoDB containers in docker

Fine if it's NOWEB and WEBJS (different engines)

patron:PRO

devlikepro commented 3 weeks ago

ok, we'll try to find why the session not got restarted after the handshake timeout, that's weird.

patron:PRO

HuangDaHui commented 3 weeks ago

I run 2 MongoDB containers in docker

Fine if it's NOWEB and WEBJS (different engines)

patron:PRO

`--WEBJS docker run -it -p 15000:3000/tcp --restart=always -e "WHATSAPP_DEFAULT_ENGINE=WEBJS" -e WHATSAPP_SESSIONS_MONGO_URL=mongodb://192.168.18.170:27017/ -e WHATSAPP_FILES_LIFETIME=0 -e WHATSAPP_RESTART_ALL_SESSIONS=True devlikeapro/waha-plus:chrome

docker run -it -p 15001:3000/tcp --restart=always -e "WHATSAPP_DEFAULT_ENGINE=WEBJS" -e WHATSAPP_SESSIONS_MONGO_URL=mongodb://192.168.18.170:27018/ -e WHATSAPP_FILES_LIFETIME=0 -e WHATSAPP_RESTART_ALL_SESSIONS=True devlikeapro/waha-plus:chrome

--NOWEB docker run -it -p 15100:3000/tcp --restart=always -e "WHATSAPP_DEFAULT_ENGINE=NOWEB" -e WHATSAPP_SESSIONS_MONGO_URL=mongodb://192.168.18.170:27017/ -e WHATSAPP_FILES_LIFETIME=0 -e WHATSAPP_RESTART_ALL_SESSIONS=True devlikeapro/waha-plus

docker run -it -p 15101:3000/tcp --restart=always -e "WHATSAPP_DEFAULT_ENGINE=NOWEB" -e WHATSAPP_SESSIONS_MONGO_URL=mongodb://192.168.18.170:27018/ -e WHATSAPP_FILES_LIFETIME=0 -e WHATSAPP_RESTART_ALL_SESSIONS=True -e WAHA_AUTO_START_DELAY_SECONDS=1 devlikeapro/waha-plus`

This is the command I currently use to run WAHA. I don’t know if there is anything that needs to be adjusted. Everything is normal with NOWEB at port 15100:3000, and everything is normal with WEBJS. NOWEB with only port 15101:3000 often gets stuck and the container exits.

HuangDaHui commented 3 weeks ago

In addition, I would like to ask if it is possible not to restart if the sessions are in the scan qr code state? Because I think it doesn't make sense, restarting just takes up resources

devlikepro commented 3 weeks ago

sessions are in the scan qr code state

If you stop it - it'll remember the state and won't restart it after container restart (with WHATSAPP_RESTART_ALL_SESSIONS=False and WAHA_WORKER_RESTART_SESSIONS=True)

patron:PRO

HuangDaHui commented 3 weeks ago

sessions are in the scan qr code state

If you stop it - it'll remember the state and won't restart it after container restart (with WHATSAPP_RESTART_ALL_SESSIONS=False and WAHA_WORKER_RESTART_SESSIONS=True)

patron:PRO

ok let me try

HuangDaHui commented 3 weeks ago

@HuangDaHui Do you use a single MongoDB with multiple WAHA workers by any change? Lioke multiple docker container but with the same MONGO_URL string? If yes - you need to setup WAHA_WORKER_ID=waha{ID} for each container (unique one)

Could you try to add WAHA_WORKER_RESTART_SESSIONS=False - in this case after restart all sessions will be stopped

patron:PRO

Hello, WAHA_WORKER_ID=waha{ID} After setting the ID, multiple NOWEBs can use the same MongoDB, right?

devlikepro commented 3 weeks ago

After setting the ID, multiple NOWEBs can use the same MongoDB, right?

Yes and make sure to set WHATSAPP_RESTART_ALL_SESSIONS=False as well. Do not run the same session on two workers, no protection for it right now. On two NOWEB workers you'll see "STOPPED" sessions from the different worker

Here's example for docker-compose https://github.com/devlikeapro/waha/blob/core/docker-compose/docker-compose.workers.yaml

patron:PRO

HuangDaHui commented 2 weeks ago

After setting the ID, multiple NOWEBs can use the same MongoDB, right?

Yes and make sure to set WHATSAPP_RESTART_ALL_SESSIONS=False as well. Do not run the same session on two workers, no protection for it right now. On two NOWEB workers you'll see "STOPPED" sessions from the different worker

Here's example for docker-compose https://github.com/devlikeapro/waha/blob/core/docker-compose/docker-compose.workers.yaml

patron:PRO

OK, thank you