mirror of
https://github.com/cheveguerra/whatsapp-api-tutorial.git
synced 2026-04-18 03:39:27 +00:00
Add auto reauth when failure
This commit is contained in:
5
app.js
5
app.js
@@ -34,6 +34,7 @@ app.get('/', (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
|
restartOnAuthFail: true,
|
||||||
puppeteer: {
|
puppeteer: {
|
||||||
headless: true,
|
headless: true,
|
||||||
args: [
|
args: [
|
||||||
@@ -110,6 +111,10 @@ io.on('connection', function(socket) {
|
|||||||
|
|
||||||
client.on('disconnected', (reason) => {
|
client.on('disconnected', (reason) => {
|
||||||
socket.emit('message', 'Whatsapp is disconnected!');
|
socket.emit('message', 'Whatsapp is disconnected!');
|
||||||
|
fs.unlinkSync(SESSION_FILE_PATH, function(err) {
|
||||||
|
if(err) return console.log(err);
|
||||||
|
console.log('Session file deleted!');
|
||||||
|
});
|
||||||
client.destroy();
|
client.destroy();
|
||||||
client.initialize();
|
client.initialize();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
socket.on('qr', function(src) {
|
socket.on('qr', function(src) {
|
||||||
$('#qrcode').attr('src', src);
|
$('#qrcode').attr('src', src);
|
||||||
|
$('#qrcode').show();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('ready', function(data) {
|
socket.on('ready', function(data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user