wppconnect icon indicating copy to clipboard operation
wppconnect copied to clipboard

Loading Session Already Paired

Open stafocher opened this issue 2 years ago • 5 comments

Hello guys,

Already completed a robot in WPPConnect and it works.

The only problem is when I do some update on WPPConnect or from time to time the compared devices fall and need to scan or QRCode again. This without anyone disconnecting or deleting the device's pairing.

I create a .js file for each client, that is, each file creates a startCLIENTNAME(client). Temporary solution.

Tokens created and organized automatically by Wpp are correct in the masses, however, they do not load.

Here's my code:

		const NOMESESSAO = 'stafocher';
		wppconnect.create({
			session: NOMESESSAO,
			//Exportando QRCode de validação do whatsapp
			catchQR: (base64Qr, asciiQR) => {
			  console.log(asciiQR); // Optional to log the QR in the terminal
			  var matches = base64Qr.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/),
				response = {};
			  if (matches.length !== 3) {
				return new Error('[MSG4] Erro de entrada de String.');
			  }
			  response.type = matches[1];
			  response.data = new Buffer.from(matches[2], 'base64');
			  var imageBuffer = response;
			  require('fs').writeFile(
				'/home/hyperbytetec/public_html/hyperwhats/qrcode/' + NOMESESSAO + '_out.png',
				imageBuffer['data'],
				'binary',
				function (err) {
				  if (err != null) {
					console.log(err);
				  }
				}
			  );
			},
			logQR: false, //Exibir QRCode no terminal? = true (sim) - false (não)
			////////////////////////////////////////////
			autoClose: false,
			useChrome: false,
			puppeteerOptions: { args: ['--no-sandbox'] },
			statusFind: (statusSession, session) => {
				console.log('[MSG5] WPPConnect iniciado com sucesso para ' + NOMESESSAO);
				//Criando arquivo contendo o status da conexão do QRCode
				if (statusSession == 'inChat'){
					//fs.rm('/home/hyperbytetec/public_html/hyperwhats/qrcode/' + NOMESESSAO + '_out.png', { recursive:true }, (err) => {});
					const myConsole = new console.Console(fs.createWriteStream('/home/hyperbytetec/public_html/hyperwhats/qrcode/' + element.NOMESESSAO + '_log_conect.txt'));
					myConsole.log('Status da conexão: Conectado!'); //Salvando status da sessão no arquivo txt
				}else{
					const myConsole = new console.Console(fs.createWriteStream('/home/hyperbytetec/public_html/hyperwhats/qrcode/' + element.NOMESESSAO + '_log_conect.txt'));
					myConsole.log('Status da conexão: Aguardando você scannear o QRCode...'); //Salvando status da sessão no arquivo txt
				}
				console.log('Status Session: ', statusSession);
				console.log('Session name: ', session);
			},
			multidevice: true,
			folderNameToken: 'tokens',
			devtools: false,
			debug: false,
			headless: true, //False abre no Chrome - True abre no console
			//browserSessionToken: browserSessionToken,
		})
		.then(async (client) => start1a99(client)) //INICIANDO ROBÔ NO LUGAR DE START(CLIENTE)
		.catch((error) => console.log(error));

image

See that the tokens were created correctly

How to inject the token created when creating the client without having to AGAIN Scan the QRCode?

See in the image that even with the token created properly, it keeps asking for the QRCode.

Thanks in advance guys for the help!

stafocher avatar Sep 21 '22 15:09 stafocher

Can anyone help me?

stafocher avatar Sep 23 '22 22:09 stafocher

In fact, I have same problem with you, it will be needed to scan QR code randomly...

momokang avatar Sep 26 '22 13:09 momokang

Is there no way to reuse a previously paired session? The customer did nothing! Didn't even unplug the device.

I actually want instructions to load that token. I'm not getting.

More detailed information about loading token applied to the example should do the trick.

Somebody?

stafocher avatar Sep 26 '22 19:09 stafocher

7 / 5 000 Somebody?

stafocher avatar Oct 01 '22 21:10 stafocher

nobody?

stafocher avatar Oct 07 '22 22:10 stafocher

what version of wppconnect you use?

antirek avatar Oct 11 '22 07:10 antirek