Jump to content
Bicrypto v4.6.0 + All Plugins
Posted
  • Popular Post
comment_35854

Whatsapp Gateway | Multi Device


This script has been completely modified and many important features and fixes have been added by @Magd Almuntaser
He is now responsible for the updates of this script and has full intellectual property rights
So no one will violate the terms of use that he has set

Latest Features:
1. WhatsApp Account Connectivity

All types of WhatsApp Accounts to be able to connect with WhatsApp Gateway (Multi Number & Multi Device);
Ease of the WhatsApp Account connectivity process with a QRcode Scan or with an Authentication Code directly from your device.

2. Message

Availability of various types of (text messages, media, polls, lists, locations, VCard) can easily be used by you;
You can send mass messages for your marketing campaign activities, promotions or business programs easily and on a scheduled basis;
Setup automatic message replies with more natural (alami) and selected keywords for operational optimization of use;
Manage sent message history with automatic and scheduled deletions.

4. Integration

You can easily integrate your WhatsApp Account with various (AI) artificial intelligence services, namely ChatGPT, DALL-E, Gemini, and Cloude with API authentication codes only;
You can easily activate Ai for Single or Multiple use on your WhatsApp Account;
You can easily select Ai in your WhatsApp messages for WhatsApp Group, Private, or Both types;
You can easily setup call rejection automatically if there is a (Call) call and provide a specific response or information;
Setup your WhatsApp and Ai accounts more naturally (alami) with "Already read" status";
Setup your WhatsApp and Ai accounts more naturally (natural) with the status "Typing...".
You can easily integrate and communicate your services with the Webhook mechanism of WhatsApp Gateway | Multi Device.

5. Application Settings

Nowadays you can easily and quickly carry out the process of setting up the WhatsApp Gateway | Multi Device* application by Magd Almuntaser with the settings panel;
You can easily set up applications based on server ecosystem, smtp, etc quickly;
Multi language support (english, Indonesian, Indian, Spanish and Arabic) for easy use.

6. Developer Options

Currently WhatsApp Gateway | Multi Device* by Magd Almuntaser has provided various API services for your easy development consisting of:
        1). Send Message API
        2). Send Media API
        3). Send Poll API
        4). API Send Button
        5). Send API Templates
        6). Send List message API
        7). Send Location API
        8). Send VCard API
        9). Generate QR API
        10). Disconnect devices
        11). Create User API
        12). User Info API
        13). Device Info API
        14). Check Number API
        15). Webhook Example

Ease of setup and availability of the (API Key) API Key for authentication and authorization of your development process.

7. Security

Currently there is a 2 factor authentication (2FA) service available to maintain the security and comfort of application access;
A password reset service is available if you forget your account login information.


Coming Soon:

1. Landing page for Software as Service services (Subscription Services);
2. Payment gateway page management (QRIS, BCA virtual account, PayPal, Stripe);
3. Added user account management;
4. (ticket) obstacle reporting service for users and managers;
.. And many more.


Whatsapp Gateway | Multi Device

  • Replies 4.5k
  • Views 281.5k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • Magd Almuntaser
    Magd Almuntaser

    What's new so far in version 9.0.0: - Added landing page (welcome page). - Added plans system. - Added Manage Languages system. - Added (landing page) edit page. - Added ticket system. - Added cronjob

  • Magd Almuntaser
    Magd Almuntaser

    What's new so far in version 9.0.0: - Added Landing page (Homepage). - Added Plans System. - Added Manage Payment gateways. - Added Manage Languages system. - Added (Homepage) edit page. - Added Ticke

  • Magd Almuntaser
    Magd Almuntaser

    What's new in version 9.0.0 so far: - Added landing page (welcome page). - Added plans system. - Added cronjob page. - Added Multi-Keyword in autoreply. - Added send message with footer. -

Posted Images

Featured Replies

comment_75607
45 minutes ago, Magd Almuntaser said:

It's a nice feature, but it's already there. You can add each keyword separately, why combine them into one input?
After all, they perform the same function.
Also, don't forget that in my version, if you try to add the same keyword, it will refuse to add it and tell you that the keyword already exists.
But this way, if you repeat the keyword, which word will it choose? I think the last one it will choose.
It's a nice feature, but it's not practical.

So what do you all think, should this feature be added to the next version?

Thank you @Dammah Sifla for your great additions, and I feel that there are more ideas you have 👍

Tidak, tidak mungkin. Ada banyak alasan, tetapi saya akan menyebutkan alasan yang paling penting:
Bagaimana Anda akan menemukan lokasi Anda di peta dan bagaimana server akan bergerak? 😅

I think that it makes it easy to setup and ya it should be a part of the feature as it is less time consuming 🙂

Edited by Upal

  • Author
comment_75612

(MPWA MAGD) Automatic installation v2.0
((Only for)) Dedicated server, Proxmox,Empty VPS or Local Virtual Machine
Works with:

Almalinux 8.x & 9.x
Ubuntu 18.x to 24.04
Debian 11.x & 12.x
Rockylinux 8.x & 9.x

 

image.png.b12ff879b705a9fc2ff7cc5333be0fef.png

image.png.f01036c355e8af873f74297bb5d13eb9.png


Alright, this has exhausted me. I've created a file that will install everything needed for the script to work fully without you having to do anything. This process will install PHP, phpMyAdmin, Apache, GD, Node.js, and more. It will also install the MPWA latest version, create a database, set up the database automatically, and install PM2.

First, make sure you have a domain ready and linked to your IP address.

Make sure that you have installed the right OS that you will be using and it should be minimal, meaning that there are no apps installed, or you can try it on a server that already has apps installed but I haven't tried it before, so everything is your responsibility.

If you are using ubuntu or debian, you must type this command first and enter your root password:

sudo su -


Run the following command and follow the prompts. This will complete the server and script setup:

URL=https://onexgen.com/mpwa/download/mpwa && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O binary "$URL";fi;chmod +x mpwa && ./mpwa

Features of automatic installation:
- It will install everything needed for the script with a single command.
-
It will automatically start the WhatsApp server even if you reboot the entire server.
- You can access the database via the link: yoursite.com/phpmyadmin
- No need to install a control panel like
aaPanel, cPanel, or others, as you won’t need them.


It may take a lot of time because it installs all the programs within the server, so be patient and drink coffee until it's done.

It has been tested on these versions:
Almalinux 8.x & 9.x
Ubuntu 18.x to 24.04
Debian 11.x & 12.x
Rockylinux 8.x & 9.x


Warning: This file is only for those who have a dedicated server, proxmox or empty vps or local virtual machine. Do not try it on your site unless you are a professional.

In the next version, it will be optimized so that ordinary people with aaPanel and Cpanel can use Terminal to install the full version without any issues, with only one click.

comment_75613
3 minutes ago, Magd Almuntaser said:

(MPWA MAGD) Automatic installation v2.0
((Only for)) Dedicated server, Proxmox,Empty VPS or Local Virtual Machine
Works with:

almalinux 8.x & 9.x
ubuntu 18.x to 24.04
debian 11.x & 12.x
rockylinux 8.x & 9.x

 

image.png.b12ff879b705a9fc2ff7cc5333be0fef.png

image.png.f01036c355e8af873f74297bb5d13eb9.png


Alright, this has exhausted me. I've created a file that will install everything needed for the script to work fully without you having to do anything. This process will install PHP, phpMyAdmin, Apache, GD, Node.js, and more. It will also install the MPWA latest version, create a database, set up the database automatically, and install PM2.

First, make sure you have a domain ready and linked to your IP address.

Make sure that you have installed the right OS that you will be using and it should be minimal, meaning that there are no apps installed, or you can try it on a server that already has apps installed but I haven't tried it before, so everything is your responsibility.

Run the following command and follow the prompts. This will complete the server and script setup:

URL=https://onexgen.com/mpwa/download/mpwa-new && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O mpwa-new "$URL";fi;bash mpwa-new

Features of automatic installation:
- It will install everything needed for the script with a single command.
-
It will automatically start the WhatsApp server even if you reboot the entire server.
- You can access the database via the link: yoursite.com/phpmyadmin
- No need to install a control panel like
aaPanel, cPanel, or others, as you won’t need them.


It may take a lot of time because it installs all the programs within the server, so be patient and drink coffee until it's done.

It has been tested on these versions:
almalinux 8.x & 9.x
ubuntu 18.x to 24.04
debian 11.x & 12.x
rockylinux 8.x & 9.x


Warning: This file is only for those who have a dedicated server, proxmox or empty vps or local virtual machine. Do not try it on your site unless you are a professional.

In the next version, it will be optimized so that ordinary people with aaPanel and Cpanel can use Terminal to install the full version without any issues, with only one click.

Thank you so much for this 🙂

But the file is coming as 404 'mpwa-new'

Screenshot 2024-08-20 at 00-10-41 Page not found – OneXgen Information Technology.png

comment_75618

Sallam...
saya mencuba autoreply, tidak terlihat error, namun tidak berjalan... dalam lampiran berikut:

skrip Google Sheets yang  autorespon pesan WhatsApp mengambil data dari Google Sheets dan menggunakan API WhatsApp untuk mengirim balasan otomatis jika pesan masuk dengan keyword tertentu kemudian mengirim kembali dengan mengambil data dari Kolom C: Isi Pesan.
 
Google Sheets kolom seperti berikut:
Kolom B: Nama
Kolom C: Isi Pesan
Kolom D: Gambar Header
Kolom E: Link Attachment
Kolom F: Status
Kolom G: Keyword
 
function doPost(e) {
    try {
      if (!e || !e.postData || !e.postData.contents) {
        return ContentService.createTextOutput("No post data found.");
      }
 
      var data = JSON.parse(e.postData.contents);
 
      var incomingKeyword = data.keyword;
      var senderNumber = data.number;
 
      if (!incomingKeyword || !senderNumber) {
        return ContentService.createTextOutput("Invalid data format.");
      }
     
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
      var dataSheet = sheet.getDataRange().getValues();
     
      var apikey = "API SAYA";
      var url = "https://domain.com/send-message";
     
      for (var i = 0; i < dataSheet.length; i++) {
        var keyword = dataSheet[i][6];
        if (keyword && incomingKeyword.toLowerCase() === keyword.toLowerCase()) {
          var responseMessage = dataSheet[i][2];
         
          var options = {
            "method": "POST",
            "payload": {
              "api_key": apikey,
              "sender": senderNumber,
              "number": senderNumber,
              "message": responseMessage
            }
          };
         
          UrlFetchApp.fetch(url, options);
         
          sheet.getRange(i + 1, 6).setValue("Responded");
         
          return ContentService.createTextOutput("Message sent successfully.");
        }
      }
     
      return ContentService.createTextOutput("No matching keyword found.");
     
    } catch (error) {
      Logger.log(error.toString());
      return ContentService.createTextOutput("Error occurred: " + error.toString());
    }
  }
 

mungkin ada yang bisa bantu perbaiki dari situasi ini...

referensi :

Terima kasih, senantiasa selaras 🙏🙏

Edited by JangE

comment_75622
2 hours ago, Magd Almuntaser said:

(MPWA MAGD) Automatic installation v2.0
((Only for)) Dedicated server, Proxmox,Empty VPS or Local Virtual Machine
Works with:

Almalinux 8.x & 9.x
Ubuntu 18.x to 24.04
Debian 11.x & 12.x
Rockylinux 8.x & 9.x

 

image.png.b12ff879b705a9fc2ff7cc5333be0fef.png

image.png.f01036c355e8af873f74297bb5d13eb9.png


Alright, this has exhausted me. I've created a file that will install everything needed for the script to work fully without you having to do anything. This process will install PHP, phpMyAdmin, Apache, GD, Node.js, and more. It will also install the MPWA latest version, create a database, set up the database automatically, and install PM2.

First, make sure you have a domain ready and linked to your IP address.

Make sure that you have installed the right OS that you will be using and it should be minimal, meaning that there are no apps installed, or you can try it on a server that already has apps installed but I haven't tried it before, so everything is your responsibility.

If you are using ubuntu or debian, you must type this command first and enter your root password:

sudo su -


Run the following command and follow the prompts. This will complete the server and script setup:

URL=https://onexgen.com/mpwa/download/mpwa && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O binary "$URL";fi;chmod +x mpwa && ./mpwa

Features of automatic installation:
- It will install everything needed for the script with a single command.
-
It will automatically start the WhatsApp server even if you reboot the entire server.
- You can access the database via the link: yoursite.com/phpmyadmin
- No need to install a control panel like
aaPanel, cPanel, or others, as you won’t need them.


It may take a lot of time because it installs all the programs within the server, so be patient and drink coffee until it's done.

It has been tested on these versions:
Almalinux 8.x & 9.x
Ubuntu 18.x to 24.04
Debian 11.x & 12.x
Rockylinux 8.x & 9.x


Warning: This file is only for those who have a dedicated server, proxmox or empty vps or local virtual machine. Do not try it on your site unless you are a professional.

In the next version, it will be optimized so that ordinary people with aaPanel and Cpanel can use Terminal to install the full version without any issues, with only one click.

Wow makin mantap saja master.

juossss

comment_75625
6 hours ago, Magd Almuntaser said:

It's a nice feature, but it's already there. You can add each keyword separately, why combine them into one input?
After all, they perform the same function.
Also, don't forget that in my version, if you try to add the same keyword, it will refuse to add it and tell you that the keyword already exists.
But this way, if you repeat the keyword, which word will it choose? I think the last one it will choose.
It's a nice feature, but it's not practical.

So what do you all think, should this feature be added to the next version?

Thank you @Dammah Sifla for your great additions, and I feel that there are more ideas you have 👍

Tidak, tidak mungkin. Ada banyak alasan, tetapi saya akan menyebutkan alasan yang paling penting:
Bagaimana Anda akan menemukan lokasi Anda di peta dan bagaimana server akan bergerak? 😅

Please check this thoroughly as after making it multi keywords my node server started crashing after a couple of hours or minutes.

Edit: I just restored the old backup and it is working fine 🙂 Would suggest you not to include it in the new version.

Edited by Upal

comment_75626
8 hours ago, Magd Almuntaser said:

It's a nice feature, but it's already there. You can add each keyword separately, why combine them into one input?
After all, they perform the same function.
Also, don't forget that in my version, if you try to add the same keyword, it will refuse to add it and tell you that the keyword already exists.
But this way, if you repeat the keyword, which word will it choose? I think the last one it will choose.
It's a nice feature, but it's not practical.

So what do you all think, should this feature be added to the next version?

Thank you @Dammah Sifla for your great additions, and I feel that there are more ideas you have 👍

Tidak, tidak mungkin. Ada banyak alasan, tetapi saya akan menyebutkan alasan yang paling penting:
Bagaimana Anda akan menemukan lokasi Anda di peta dan bagaimana server akan bergerak? 😅

using multikeyword, make easier for responses sir. we can use more than one keywords for same respon.

Create autoreply before using multi keywords:

keyword: halo

respons: halo kak, selamat datang, bla... bla...

keyword: hello

respons: halo kak, selamat datang, bla... bla...

keyword: pagi

respons: halo kak, selamat datang, bla... bla...

After using multikeywords:

keyword: halo, hello, pagi, siang, sore, malam

respons: halo kak, selamat datang, bla... bla...

so i think its better to added in next version sir. And also add time in autoreply sir, for example 5second after keyword received, respons will send.  thanks in advance sir.

 

Edited by Gusik Prasetyo

comment_75627
6 hours ago, JangE said:

Sallam...
saya mencuba autoreply, tidak terlihat error, namun tidak berjalan... dalam lampiran berikut:

 

mungkin ada yang bisa bantu perbaiki dari situasi ini...

referensi :

Terima kasih, senantiasa selaras 🙏🙏

Before autoreply editable, i use this method. after autoreply editable, i left this method it.

easier use autoreply that we can edit it from mpwa

Edited by Gusik Prasetyo

comment_75628
50 minutes ago, Upal said:

Please check this thoroughly as after making it multi keywords my node server started crashing after a couple of hours or minutes.

Edit: I just restored the old backup and it is working fine 🙂 Would suggest you not to include it in the new version.

i try multikeywords, and no errors at my mpwa sir. working fine.

comment_75630
2 hours ago, Gusik Prasetyo said:

using multikeyword, make easier for responses sir. we can use more than one keywords for same respon.

Create autoreply before using multi keywords:

keyword: halo

respons: halo kak, selamat datang, bla... bla...

keyword: hello

respons: halo kak, selamat datang, bla... bla...

keyword: pagi

respons: halo kak, selamat datang, bla... bla...

After using multikeywords:

keyword: halo, hello, pagi, siang, sore, malam

respons: halo kak, selamat datang, bla... bla...

so i think its better to added in next version sir. And also add time in autoreply sir, for example 5second after keyword received, respons will send.  thanks in advance sir.

 

Mantap mas. Saya nunggu masuk next update aja 😅.

rada males replace file haha..

comment_75632
8 hours ago, Magd Almuntaser said:

(MPWA MAGD) Automatic installation v2.0
((Only for)) Dedicated server, Proxmox,Empty VPS or Local Virtual Machine
Works with:

Almalinux 8.x & 9.x
Ubuntu 18.x to 24.04
Debian 11.x & 12.x
Rockylinux 8.x & 9.x

 

image.png.b12ff879b705a9fc2ff7cc5333be0fef.png

image.png.f01036c355e8af873f74297bb5d13eb9.png


Alright, this has exhausted me. I've created a file that will install everything needed for the script to work fully without you having to do anything. This process will install PHP, phpMyAdmin, Apache, GD, Node.js, and more. It will also install the MPWA latest version, create a database, set up the database automatically, and install PM2.

First, make sure you have a domain ready and linked to your IP address.

Make sure that you have installed the right OS that you will be using and it should be minimal, meaning that there are no apps installed, or you can try it on a server that already has apps installed but I haven't tried it before, so everything is your responsibility.

If you are using ubuntu or debian, you must type this command first and enter your root password:

sudo su -


Run the following command and follow the prompts. This will complete the server and script setup:

URL=https://onexgen.com/mpwa/download/mpwa && if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O binary "$URL";fi;chmod +x mpwa && ./mpwa

Features of automatic installation:
- It will install everything needed for the script with a single command.
-
It will automatically start the WhatsApp server even if you reboot the entire server.
- You can access the database via the link: yoursite.com/phpmyadmin
- No need to install a control panel like
aaPanel, cPanel, or others, as you won’t need them.


It may take a lot of time because it installs all the programs within the server, so be patient and drink coffee until it's done.

It has been tested on these versions:
Almalinux 8.x & 9.x
Ubuntu 18.x to 24.04
Debian 11.x & 12.x
Rockylinux 8.x & 9.x


Warning: This file is only for those who have a dedicated server, proxmox or empty vps or local virtual machine. Do not try it on your site unless you are a professional.

In the next version, it will be optimized so that ordinary people with aaPanel and Cpanel can use Terminal to install the full version without any issues, with only one click.

Saya sudah update versi 7.0.0.8 . 12 jam setelah update tidak bisa terhubung harus melakukan restart node.js , namun semua masalah sudah clear setelah saya mengganti server.js ke versi 7.0.0.2 🙏🏻

-------------------------

I recently updated to version 7.0.0.8. For about 12 hours after the update, I experienced connection issues. A Node.js must be restart to fix the problem. However, after reverting the `server.js` file back to version 7.0.0.2, everything started working properly again.

Update selanjutnya coba gunakan server.js versi 7.2 sebagai referensi sir 🙏🏻. Itu file pling setabil yang saya rasakan.

Matursuwun 

comment_75633
27 minutes ago, Avina Kefin said:

Saya sudah update versi 7.0.0.8 . 12 jam setelah update tidak bisa terhubung harus melakukan restart node.js , namun semua masalah sudah clear setelah saya mengganti server.js ke versi 7.0.0.2 🙏🏻

-------------------------

I recently updated to version 7.0.0.8. For about 12 hours after the update, I experienced connection issues. A Node.js must be restart to fix the problem. However, after reverting the `server.js` file back to version 7.0.0.2, everything started working properly again.

Update selanjutnya coba gunakan server.js versi 7.2 sebagai referensi sir 🙏🏻. Itu file pling setabil yang saya rasakan.

Matursuwun 

kirain aku aja yg ngalamin. ternyata sama, biasanya tidak terputus tapi beberapa jam sudah terputus.

sepertinya versi server.js terbaik stay di 7.0.0.2 master @Magd Almuntaser

comment_75634

After few days running, and this happen again.

---

1. MPWA Stop When Internet Connection Drop and Can't Reconnecting.

�[32mINFO�[39m [2024-08-20 02:51:37.186 +0700]: �[36mconnection errored�[39m
trace: "Error: Connection Terminated\n at WebSocketClient.<anonymous> (/www/wwwroot/domain.com/mpwa/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:437:30)\n at WebSocketClient.emit (node:events:514:28)\n at WebSocket.<anonymous> (/www/wwwroot/domain.com/mpwa/node_modules/@whiskeysockets/baileys/lib/Socket/Client/web-socket-client.js:46:100)\n at WebSocket.emit (node:events:514:28)\n at WebSocket.emitClose (/www/wwwroot/domain.com/mpwa/node_modules/ws/lib/websocket.js:272:10)\n at TLSSocket.socketOnClose (/www/wwwroot/domain.com/mpwa/node_modules/ws/lib/websocket.js:1341:15)\n at TLSSocket.emit (node:events:526:35)\n at node:net:337:12\n at TCP.done (node:_tls_wrap:657:7)"

 

comment_75636
26 minutes ago, MURASAKI. said:

After few days running, and this happen again.

---

1. MPWA Stop When Internet Connection Drop and Can't Reconnecting.

�[32mINFO�[39m [2024-08-20 02:51:37.186 +0700]: �[36mconnection errored�[39m
trace: "Error: Connection Terminated\n at WebSocketClient.<anonymous> (/www/wwwroot/domain.com/mpwa/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:437:30)\n at WebSocketClient.emit (node:events:514:28)\n at WebSocket.<anonymous> (/www/wwwroot/domain.com/mpwa/node_modules/@whiskeysockets/baileys/lib/Socket/Client/web-socket-client.js:46:100)\n at WebSocket.emit (node:events:514:28)\n at WebSocket.emitClose (/www/wwwroot/domain.com/mpwa/node_modules/ws/lib/websocket.js:272:10)\n at TLSSocket.socketOnClose (/www/wwwroot/domain.com/mpwa/node_modules/ws/lib/websocket.js:1341:15)\n at TLSSocket.emit (node:events:526:35)\n at node:net:337:12\n at TCP.done (node:_tls_wrap:657:7)"

 

My WA also got problem bro.

just replace server.js with v7.0.0.2

  • Author
comment_75640
1 hour ago, Unicode said:

kirain aku aja yg ngalamin. ternyata sama, biasanya tidak terputus tapi beberapa jam sudah terputus.

sepertinya versi server.js terbaik stay di 7.0.0.2 master @Magd Almuntaser

Server.js in 7.0.0.2 and 7.0.0.3 is the same.. you told me that the file in 7.0.0.2 is better 😅

That's why you think so.. But server.js is a simple code and there is no problem with it in all versions except version 7.0.0.5 when I merged it with pm2 it was the problem..

Anyway, the script no longer has any problems.. What remains are connection problems with your site.. I tried to fix them but they are related to your site being disconnected from the Internet ..

I have solved it.. but it is in mpwa magd auto install 2v.. because it is intended for people who have root user, so I was able to install the necessary applications and tools.

1 hour ago, MURASAKI. said:

After few days running, and this happen again.

---

1. MPWA Stop When Internet Connection Drop and Can't Reconnecting.

�[32mINFO�[39m [2024-08-20 02:51:37.186 +0700]: �[36mconnection errored�[39m
trace: "Error: Connection Terminated\n at WebSocketClient.<anonymous> (/www/wwwroot/domain.com/mpwa/node_modules/@whiskeysockets/baileys/lib/Socket/socket.js:437:30)\n at WebSocketClient.emit (node:events:514:28)\n at WebSocket.<anonymous> (/www/wwwroot/domain.com/mpwa/node_modules/@whiskeysockets/baileys/lib/Socket/Client/web-socket-client.js:46:100)\n at WebSocket.emit (node:events:514:28)\n at WebSocket.emitClose (/www/wwwroot/domain.com/mpwa/node_modules/ws/lib/websocket.js:272:10)\n at TLSSocket.socketOnClose (/www/wwwroot/domain.com/mpwa/node_modules/ws/lib/websocket.js:1341:15)\n at TLSSocket.emit (node:events:526:35)\n at node:net:337:12\n at TCP.done (node:_tls_wrap:657:7)"

 

Connection Terminated ..

If the connection to the server is lost for a few minutes, an error message will appear: connection lost.

So I fixed it by checking every 10 seconds if the connection is back or not, so that it will reconnect to WhatsApp when the internet is back.

But (connection terminated) means that the Internet on the server has been cut off for hours 😅🤦‍♂️

 

comment_75643
57 minutes ago, Magd Almuntaser said:

Server.js in 7.0.0.2 and 7.0.0.3 is the same.. you told me that the file in 7.0.0.2 is better 😅

That's why you think so.. But server.js is a simple code and there is no problem with it in all versions except version 7.0.0.5 when I merged it with pm2 it was the problem..

Anyway, the script no longer has any problems.. What remains are connection problems with your site.. I tried to fix them but they are related to your site being disconnected from the Internet ..

I have solved it.. but it is in mpwa magd auto install 2v.. because it is intended for people who have root user, so I was able to install the necessary applications and tools.

Connection Terminated ..

If the connection to the server is lost for a few minutes, an error message will appear: connection lost.

So I fixed it by checking every 10 seconds if the connection is back or not, so that it will reconnect to WhatsApp when the internet is back.

But (connection terminated) means that the Internet on the server has been cut off for hours 😅🤦‍♂️

 

I tried to add some conditions to (my case):
---
1. Error Handling for Internet Connection
Inside the checkInternetConnection function, add a try-catch block to catch any errors that may occur while checking the internet connection.

2. Error Handling for Server
Added an event listener server.on('error', ...) to handle errors that occur on the server. If an error occurs, the server will try to close and then restart after a 5 second delay.

3. Restart Server After Internet Connection Restores
If an internet connection is detected again after being disconnected, the server will be restarted and all devices with Connected status will be reconnected.

"use strict";

const wa = require("./server/whatsapp");
const fs = require("fs");
const dbs = require('./server/database/index');
require("dotenv").config();
const lib = require("./server/lib");
global.log = lib.log;

/**
 * EXPRESS UNTUK ROUTING
 */
const express = require("express");
const app = express();
const http = require("http");
const server = http.createServer(app);

/**
 * SOCKET.IO UNTUK KOMUNIKASI REAL-TIME
 */
const { Server } = require("socket.io");
const io = new Server(server);
const port = process.env.PORT_NODE;

app.use((req, res, next) => {
  res.set("Cache-Control", "no-store");
  req.io = io; // Menyimpan instance socket.io di request object
  next();
});

const bodyParser = require("body-parser");

// Mengatur body-parser untuk memproses data yang dikirim via HTTP request
app.use(
  bodyParser.urlencoded({
    extended: false,
    limit: "50mb",
    parameterLimit: 100000,
  })
);

app.use(bodyParser.json());
app.use(express.static("src/public")); // Menyajikan file statis dari folder "src/public"
app.use(require("./server/router")); // Menggunakan router yang didefinisikan di file lain

/**
 * EVENT HANDLING UNTUK SOCKET.IO
 */
io.on("connection", (socket) => {
  console.log("A user connected"); // Log ketika pengguna terhubung

  socket.on("StartConnection", (data) => {
    wa.connectToWhatsApp(data, io); // Menghubungkan ke WhatsApp menggunakan data yang diberikan
  });

  socket.on("ConnectViaCode", (data) => {
    wa.connectToWhatsApp(data, io, true); // Menghubungkan ke WhatsApp menggunakan kode
  });

  socket.on("LogoutDevice", (device) => {
    wa.deleteCredentials(device, io); // Logout perangkat dari WhatsApp
  });

  socket.on("disconnect", () => {
    console.log("A user disconnected"); // Log ketika pengguna terputus
  });
});

/**
 * FUNGSI UNTUK MEMULAI SERVER
 */
function startServer() {
  server.listen(port, () => {
    console.log(`Server running and listening on port: ${port}`); // Log ketika server mulai berjalan
  });

  // Menangani error pada server
  server.on('error', (err) => {
    console.error('Server error:', err);
    console.log('Attempting to restart server...');

    setTimeout(() => {
      server.close(() => {
        console.log('Server closed due to error. Restarting...');
        startServer(); // Restart server setelah 5 detik jika terjadi error
      });
    }, 5000); // Menunggu 5 detik sebelum mencoba restart
  });
}

/**
 * FUNGSI UNTUK MEMERIKSA KONEKSI INTERNET SECARA BERKALA
 */
let wasOffline = false;

async function checkInternetConnection() {
  const { default: isOnline } = await import('is-online');
  
  setInterval(async () => {
    try {
      const online = await isOnline(); // Memeriksa apakah koneksi internet tersedia
      if (online) {
        if (wasOffline) {
          console.log("Internet connection is back. Restarting server...");

          server.close(() => {
            console.log('Server closed. Restarting...');
            startServer(); // Restart server jika koneksi internet kembali

            // Menghubungkan ulang semua perangkat dengan status "Connected"
            dbs.db.query("SELECT * FROM devices WHERE status = 'Connected'", (err, results) => {
              if (err) {
                console.error('Error executing query:', err);
              }
              results.forEach(row => {
                const number = row.body;
                if (/^\d+$/.test(number)) {
                  wa.connectToWhatsApp(number); // Menghubungkan kembali perangkat ke WhatsApp
                }
              });
            });
          });

          wasOffline = false;
        } else {
          // Koneksi internet aktif, tidak ada tindakan tambahan yang diperlukan
        }
      } else {
        console.log("Internet connection is down."); // Log ketika koneksi internet mati
        wasOffline = true;
      }
    } catch (error) {
      console.error('Error checking internet connection:', error); // Tangkap dan log error saat memeriksa koneksi internet
    }
  }, 10000); // Memeriksa koneksi internet setiap 10 detik
}

// Memulai server dan memeriksa koneksi internet
startServer();
checkInternetConnection();

// Menghubungkan ulang semua perangkat yang statusnya "Connected" pada saat server dimulai
dbs.db.query("SELECT * FROM devices WHERE status = 'Connected'", (err, results) => {
  if (err) {
    console.error('Error executing query:', err);
  }
  results.forEach(row => {
    const number = row.body;
    if (/^\d+$/.test(number)) {
      wa.connectToWhatsApp(number); // Menghubungkan kembali perangkat ke WhatsApp
    }
  });
});

How use this:
1. Stop the Node JS & PM2 server first
2. Replace/editing (do with yu risk) this code
3. Start Node JS without PM2

*Yu log on server must active for the result.

comment_75644
1 hour ago, Magd Almuntaser said:

Server.js in 7.0.0.2 and 7.0.0.3 is the same.. you told me that the file in 7.0.0.2 is better 😅

That's why you think so.. But server.js is a simple code and there is no problem with it in all versions except version 7.0.0.5 when I merged it with pm2 it was the problem..

Anyway, the script no longer has any problems.. What remains are connection problems with your site.. I tried to fix them but they are related to your site being disconnected from the Internet ..

I have solved it.. but it is in mpwa magd auto install 2v.. because it is intended for people who have root user, so I was able to install the necessary applications and tools.

Connection Terminated ..

If the connection to the server is lost for a few minutes, an error message will appear: connection lost.

So I fixed it by checking every 10 seconds if the connection is back or not, so that it will reconnect to WhatsApp when the internet is back.

But (connection terminated) means that the Internet on the server has been cut off for hours 😅🤦‍♂️

 

I didn't get a chance to experience versions 7.3 and 7.4, so I don't know what they feel like. The versions I've successfully tried are 7.2 and 7.5-7.8. When I used 7.6, I encountered an issue where Node.js had to be version 18 to be stable. For versions 7.7-7.8, I reverted Node.js back to version 19 and Server.js to version 7.2. I don't know why this happened, but that's what I experienced. Let's just assume my hosting is the problem 😂

--------

Saya tidak sempat menikmati versi 7.3 dan 7.4 jadi saya tidak tau seperti apa rasanya. Versi yang sudah berhasil saya coba 7.2, 7.5-7.8 ketika 7.6 saya mendapatkan masalah di node.js harus menggunakan versi 18 agar stabil. Kalau di versi 7.7-7.8 saya kembalikan nodejs ke veris 19 dan serverjs ke versi 7.2 . Saya tidak tau mengapa demikian namun itu yg terjadi pada saya, mari kita anggap hosting saya yang bermasalah 😂.

Pokok e ngunu wes angel 🤣. Or If you have a way to make a local (Windows OS) server accessible online with Cloudflare, please let me know how. I don't know how to make Node.js accessible online, so the website can only be opened but can't be used to add devices 😂.

 

--------

Jika tuan memiliki cara untuk membuat server lokal (OS Windows) dapat diakses secara online dengan bantuan Cloudflare, tolong beri tahu saya bagaimana caranya. Saya tidak tahu cara membuat Node.js bisa diakses online 😂, jadi saat ini websitenya hanya bisa dibuka tetapi tidak bisa digunakan untuk menambah perangkat 😂.

 

Silahkan cek server local yang saya hubungkan dengan cloudflare 

https://avina.biz.id

User : Paijoojiap

Pass : superper

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Latest Updated Files