Jump to content

Recommended Posts

11 minutes ago, sonu kumar saini said:

THIS IS ERROR 

ReferenceError: Cannot access 'fs' before initialization
    at Object.<anonymous> (/home/kdletqgj/message.aacademy.in/server.js:10:8)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at startApplication (/usr/local/lsws/fcgi-bin/lsnode.js:48:15)
    at Object.<anonymous> (/usr/local/lsws/fcgi-bin/lsnode.js:16:1)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)

Node.js v20.14.0
/home/kdletqgj/message.aacademy.in/server.js:10
  key: fs.readFileSync('key.pem'),
       ^


MY SERVER.JS IS 
 

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 FOR ROUTING
 */
const serverOptions = {
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem')
}

const express = require("express");
const app = express();
const https = require("https");
const server = https.createServer(serverOptions, app);

/**
 * SOCKET.IO
 */
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;
  // res.set('Cache-Control', 'no-store')
  next();
});

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

// parse application/x-www-form-urlencoded
app.use(
  bodyParser.urlencoded({
    extended: false,
    limit: "50mb",
    parameterLimit: 100000,
  })
);
// parse application/json
app.use(bodyParser.json());
app.use(express.static("src/public"));
app.use(require("./server/router"));

// console.log(process.argv)

io.on("connection", (socket) => {
  socket.on("StartConnection", (data) => {
    wa.connectToWhatsApp(data, io);
  });
  socket.on("ConnectViaCode", (data) => {
    wa.connectToWhatsApp(data, io, true);
  });
  socket.on("LogoutDevice", (device) => {
    wa.deleteCredentials(device, io);
  });
});
server.listen(port, console.log(`Server run and listening port: ${port}`));

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);
      }
    });
});

Download the attcachment and replace ..
if you still have a problem, downgrade your node to v18

server.js

1 hour ago, Magd Almuntaser said:

Download the attcachment and replace ..
if you still have a problem, downgrade your node to v18

server.js 1.77 kB · 0 downloads

Sir how about problem when opening main domain ex: domain.com only show Cannot get /public.

what is the problem? I am trying installing on hosting with directadmin panel but got this error.

but if i try domain.com/login all running normal. only root domain cant accessed.

Screenshot 2024-08-06 203045.png

5 minutes ago, nikokenzo said:

Sir how about problem when opening main domain ex: domain.com only show Cannot get /public.

what is the problem? I am trying installing on hosting with directadmin panel but got this error.

but if i try domain.com/login all running normal. only root domain cant accessed.

Screenshot 2024-08-06 203045.png

The issue is in an .htaccess file that is incompatible with the directadmin panel settings Try replacing the content of the .htaccess file with the following:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} !^/socket.io/
    RewriteCond %{REQUEST_URI} !^/backend-.*
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
<IfModule mod_security.c>
  SecFilterEngine Off
  SecFilterScanPOST Off
</IfModule>

 

2 minutes ago, Magd Almuntaser said:

The issue is in an .htaccess file that is incompatible with the directadmin panel settings Try replacing the content of the .htaccess file with the following:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} !^/socket.io/
    RewriteCond %{REQUEST_URI} !^/backend-.*
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
<IfModule mod_security.c>
  SecFilterEngine Off
  SecFilterScanPOST Off
</IfModule>

 

still same sir. 

4 minutes ago, nikokenzo said:

still same sir. 

So the issue is not with the script, the issue is with the directadmin panel Check your Apache or nginx settings

Tip: I advise you not to use the directadmin control panel because of its issues and restricted control, you can follow its issues from their official website, there are many people who complain about it.

8 minutes ago, Magd Almuntaser said:

So the issue is not with the script, the issue is with the directadmin panel Check your Apache or nginx settings

Tip: I advise you not to use the directadmin control panel because of its issues and restricted control, you can follow its issues from their official website, there are many people who complain about it.

ok. i will try asking hosting provider.

I just trying directadmin, because on cpanel my whatsapp always disconnect and cannot reconnect except  i must restart node js everyday (sometimes 3 times a day).

10 hours ago, Magd Almuntaser said:

Yes, I will do that. I might release the next version today or tomorrow.
It contains many fixes and additions.
Some of these additions include:

- new page for updating the version remotely with a single click without needing to download the compressed file (smart update)
- new page for the AI bot with all options
- Added Claude API
- Added an option for (read) for bot conversations
- The ability to choose if you want to integrate more than one bot and call it by name in the conversation or not
- The ability to enable or disable calls for the bot
- Fixed the date issue in (message history)
- Fixed the port page for those using SSL
... and more

@Magd Almuntaser don't forget to tag me when you push the update

Posted (edited)

Bantu saya Fixing error, source code menggunkan v7.0 halam 41, server ubuntu 20.04 php 8.0 node version v16.20.2 pm2 version 5.3.1.
issue jika ingin connect device type setting server hosting share baru bisa, tapi pakai type server hosting, jika send message device connect dia error di gambar. dia harus pakai type server localhost baru bisa ada solusi kah min? disaat type server localhost error saat connect device WebSocket connection to 'ws://localhost:3100/socket.io/?EIO=4&transport=websocket' failed: 
window.WebSocket @ pace.min.js:1
value @ websocket.js:44
value @ transport.js:45
value @ socket.js:164
a @ socket.js:105
value @ manager.js:108
s @ manager.js:39
Pt @ index.js:29
(anonymous) @ 6282223138034:441
Show 4 more frames
Show less
 image.thumb.png.c4a74fef42a7ca596fbd98074621ed10.pngB

Edited by kenariponsel ponsel
Posted (edited)
3 hours ago, nikokenzo said:

Tuan, bagaimana dengan masalah saat membuka domain utama, misal: domain.com hanya menampilkan Tidak dapat memperoleh /publik.

Apa masalahnya? Saya mencoba menginstal di hosting dengan panel directadmin tetapi mendapatkan kesalahan ini.

tetapi jika saya mencoba domain.com/login semuanya berjalan normal. hanya domain root yang dapat diakses.

Tangkapan layar 2024-08-06 203045.png

Coba tambahkan ini pada .httaccess
 

<IfModule mod_rewrite.c>
    RewriteEngine On    
    
    RewriteCond %{REQUEST_URI} !^/socket.io/
    RewriteCond %{REQUEST_URI} !^/backend-*
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /public/$1 [L,QSA]
</IfModule>

 

Edited by Dammah Sifla
40 minutes ago, kenariponsel ponsel said:

Bantu saya Fixing error, source code menggunkan v7.0 halam 41, server ubuntu 20.04 php 8.0 node version v16.20.2 pm2 version 5.3.1.
issue jika ingin connect device type setting server hosting share baru bisa, tapi pakai type server hosting, jika send message device connect dia error di gambar. dia harus pakai type server localhost baru bisa ada solusi kah min? disaat type server localhost error saat connect device WebSocket connection to 'ws://localhost:3100/socket.io/?EIO=4&transport=websocket' failed: 
window.WebSocket @ pace.min.js:1
value @ websocket.js:44
value @ transport.js:45
value @ socket.js:164
a @ socket.js:105
value @ manager.js:108
s @ manager.js:39
Pt @ index.js:29
(anonymous) @ 6282223138034:441
Show 4 more frames
Show less
 image.thumb.png.c4a74fef42a7ca596fbd98074621ed10.pngB

Tidak ada masalah jika menggunakan shared hosting atau localhost yang penting berfungsi dengan baik. Pilih opsi yang sesuai yang dapat mengirim pesan dengan baik. Jangan khawatir tentang nama-nama tersebut, mereka hanya mengubah bentuk tautan di file .env.

Posted (edited)

solusi bagaimana tuan @Magd Almuntaser, biar tidak gonta ganti setting server karena ini, kalo mau connect harus di ubah type hosting share, kalo dah connect ubah ke localhost biar tidak muncul error di gambar, jadi contoh type bisa kirim pesan localhost tapi dia tidak bisa connect device itu cemana? kalo misal device sering gini 

Failed to send message to all number,check you whatsapp connection and try again. kenapa ya? maksud baru kirim 2 pesan dah tidak connect?
Edited by kenariponsel ponsel
4 minutes ago, kenariponsel ponsel said:

solusi bagaimana tuan @Magd Almuntaser, biar tidak gonta ganti setting server karena ini, kalo mau connect harus di ubah type hosting share, kalo dah connect ubah ke localhost biar tidak muncul error di gambar, jadi contoh type bisa kirim pesan localhost tapi dia tidak bisa connect device itu cemana? kalo misal device sering gini 

Failed to send message to all number,check you whatsapp connection and try again. kenapa ya? maksud baru kirim 2 pesan dah tidak connect?

Masalahmu sangat membingungkan karena ini pertama kali saya menemui masalah seperti ini. Tapi saya curiga kamu menggunakan tautan situsmu https bukan http.
Jika kamu menggunakan https, kamu harus mengubah tautan situsmu di browser menjadi http://
Juga, buka file .env dan lihat tautan situsmu. Jika https, ubah menjadi http karena kamu tidak menggunakan sertifikat SSL di situsmu.

3 hours ago, Dammah Sifla said:

Coba tambahkan ini pada .httaccess
 

<IfModule mod_rewrite.c>
    RewriteEngine On    
    
    RewriteCond %{REQUEST_URI} !^/socket.io/
    RewriteCond %{REQUEST_URI} !^/backend-*
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /public/$1 [L,QSA]
</IfModule>

 

Sudah ada script ini di htacceas bawaan.

anehnya ini tidak bekerja di directadmin

19 hours ago, Magd Almuntaser said:

Your hosting block symlink function ..

If you have vps you can enable this function and try again or run this command in SSH:

php artisan storage:link

If you don't have vps and you have aapanel you can create symlink from files ..

i don't have vps or aapanel. any other solution?

2 minutes ago, Jei Grey said:

node.js jalan lancar. symlinknya yang tidak bisa

Punyaku malah aneh. Di shared hosting setiap pagi kudu restart node js, krn kayak gk jalan dia. Jadinya wa gk konek.

btw hosting dimana bro?

Posted (edited)
38 minutes ago, pak kacung said:

@nikokenzo apa sudah install pm2?

ini di shared hosting pak kacung.

sedangkan nyoba di aapanel gk bisa di start nodejsnya. sudah install pm2, aku coba running dari pm2 juga ndak bisa.

sepertinya RAM vps kurang. sedangkan di shared hosting lancar, tapi setiap pagi node jsnya minta direstart kayak gk jalan 

Edited by nikokenzo

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
  • Create New...