mirror of
https://github.com/cheveguerra/whatsapp-api-tutorial.git
synced 2026-04-17 19:36:59 +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({
|
||||
restartOnAuthFail: true,
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: [
|
||||
@@ -110,6 +111,10 @@ io.on('connection', function(socket) {
|
||||
|
||||
client.on('disconnected', (reason) => {
|
||||
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.initialize();
|
||||
});
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
socket.on('qr', function(src) {
|
||||
$('#qrcode').attr('src', src);
|
||||
$('#qrcode').show();
|
||||
});
|
||||
|
||||
socket.on('ready', function(data) {
|
||||
|
||||
Reference in New Issue
Block a user