Creates an Event Driven Architecture (EDA) based on redis and rabbitmq with the aim of managing multiple sessions in whatsapp web js.
Sessions are currently saved with local auth due to a bug in the WhatsApp web js remote store.
You can have as many clusters as you want, including automatically scaling them, it works to actually work with multiple instances and multiple machines in production.
Before all: Rename the .env.example to .env.
First install all the packages:
npm install
Then init the docker services.
cd infra
docker-compose -f docker-compose.development.yml up -d
Finally, come back to the root directory and run:
Start: npm run start
Dev: npm run dev
You can have as many connected clusters as you want, it automatically detects the key and sends it to the correct instance
create_instance: recive a json containing a unique key destroy_instance: recive a json containing a unique key to destroy send_message: recive a json containing a unique key to send the message, an chat_id in format @c.us, and a message text.
authenticated_instance: a instances get authenticated: receive a body containing the key disconnected_instance: a instances get disconnected: receive a body containing the key auth_failure_instance: a instances get an auth_failure: receive a body containing the key message_instance: a instances get an message: receive a body containing the key and a message containing the message from wwebjs
The cluster stops accepting the creation of new connections when 'exceeding' the machine's resources: ram: 90% OR CPU: 90%
And receive creation again from: RAM: < 80% E CPU: < 80%
They are on redis with the key instances:{key}:qr_code
.
The rabbit mq pannel from docker should be avaible on http://localhost:15672