Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading Session Already Paired #1339

Closed
stafocher opened this issue Sep 21, 2022 · 6 comments
Closed

Loading Session Already Paired #1339

stafocher opened this issue Sep 21, 2022 · 6 comments
Labels
needs triage question Further information is requested

Comments

@stafocher
Copy link

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 stafocher added needs triage question Further information is requested labels Sep 21, 2022
@stafocher stafocher changed the title Carregando Sessão já Emparelhada Loading Session Already Paired Sep 21, 2022
@stafocher
Copy link
Author

Can anyone help me?

@momokang
Copy link

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

@stafocher
Copy link
Author

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
Copy link
Author

7 / 5 000
Somebody?

@stafocher
Copy link
Author

nobody?

@antirek
Copy link
Contributor

antirek commented Oct 11, 2022

what version of wppconnect you use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants