wppconnect icon indicating copy to clipboard operation
wppconnect copied to clipboard

sessions not working properly

Open joelvasiliev opened this issue 2 years ago • 9 comments

Description

Hi, I'm working with multiple sessions, and I do have this code:

app.post('/whatsapp/session', function (req, res) { const id = randomUUID(); wppconnect .create({ session: id, catchQR: (base64Qr) => { sessions.push({ id, client: null, qr: base64Qr.split(',')[1], error: false, }); }, headless: true, // Headless chrome useChrome: false, // If false will use Chromium instance debug: true, // Opens a debug session logQR: true, // Logs QR automatically in terminal updatesLog: true, // Logs info updates automatically in terminal autoClose: 30000, // Automatically closes the wppconnect only when scanning the QR code (default 60 seconds, if you want to turn it off, assign 0 or false) tokenStore: 'file', // Define how work with tokens, that can be a custom interface })

When I make a POST request with Postman, it works fine the first time, but on the second one, it reuses the previous token folder. Evidence:" image image

"In the second image, the ID in the session is 'f0879c68-0d88-4d20-a301-4430b7056846,' and it is using the 'tokens' folder in the path 'tokens\9e56bf2c-6fc5-44b6-a7fb-b62e48daf720,'' which would be the ID of the first request made."

Environment

  • WPPConnect version(s): 1.28.0
  • Browser: Chrome
  • OS: Windows 10
  • Node version: Node 16.13.2
  • WhatsApp version: latest
  • MultiDevice (BETA): no

joelvasiliev avatar Oct 25 '23 04:10 joelvasiliev

Hello, everything is working fine.

Try posting your complete code (with the call that reuses the session) and formatted for better readability.

For manual testing, use the pure code by directly calling the session and manually specifying the session name for your tests. This way, you can pinpoint where the issue in your code might be.

icleitoncosta avatar Nov 04 '23 14:11 icleitoncosta

Hello, I'm also having the same issues as @joelvasiliev.

When I create a new client with a new session:

this.client = await create({
				session: this.session,
				deviceName: `${name} WhatsApp Client`,
				statusFind: statusCallback,
				catchQR: qrCallback,
				waitForLogin: true,
				debug: true,
				autoClose: 60 * 2 * 1000,
				folderNameToken: `clients/whatsapp`,
				onLoadingScreen: loadingCallback,
				logQR: true,
			});

I get the following output on the console

messaging:dev: info:     [AuSMVtYpXs-cdecdae2-2e7c-4963-9578-267ea61dca59:browser] Using browser folder '/services/messaging/clients/whatsapp/cBUGNuxYVE/cBUGNuxYVE-d999f7de-e4f2-419b-8e8f-9236b7a91132'
messaging:dev: info:     [AuSMVtYpXs-cdecdae2-2e7c-4963-9578-267ea61dca59:browser] Initializing browser...
messaging:dev: 
messaging:dev:   Puppeteer old Headless deprecation warning:
messaging:dev:     In the near feature `headless: true` will default to the new Headless mode
messaging:dev:     for Chrome instead of the old Headless implementation. For more
messaging:dev:     information, please see https://developer.chrome.com/articles/new-headless/.
messaging:dev:     Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
messaging:dev:     If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

The session id is AuSMVtYpXs-cdecdae2-2e7c-4963-9578-267ea61dca59 but the first statement of the logs says the client is using browser at /services/messaging/clients/whatsapp/cBUGNuxYVE/cBUGNuxYVE-d999f7de-e4f2-419b-8e8f-9236b7a91132 which is the folder location of the other running service. This causes this session to not display the QR code and fails after an interval.

nnkogift avatar Nov 04 '23 22:11 nnkogift

device not connecting

RAKESHSUVIDYA avatar Nov 10 '23 06:11 RAKESHSUVIDYA

Session Unpaired

RAKESHSUVIDYA avatar Nov 10 '23 06:11 RAKESHSUVIDYA

error: Unhandled Rejection: ProtocolError: Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed. at <instance_members_initializer> (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:96:14) at new Callback (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:100:16) at CallbackRegistry.create (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/CallbackRegistry.js:32:26) at Connection._rawSend (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Connection.js:91:26) at CdpCDPSession.send (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/CDPSession.js:78:33) at #evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:211:50) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async ExecutionContext.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:126:16) at async IsolatedWorld.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/IsolatedWorld.js:128:16) at async CdpFrame.evaluate (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Frame.js:370:20)

RAKESHSUVIDYA avatar Nov 10 '23 07:11 RAKESHSUVIDYA

debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (CONNECTING) debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (CONNECTING) info: Auto close configured to 180s http: Checking phone is connected... debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (CONNECTING) debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (CONNECTING) debug: Registering onStateChange event debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (SYNCING)

RAKESHSUVIDYA avatar Nov 10 '23 07:11 RAKESHSUVIDYA

debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (CONNECTING) debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (CONNECTING) info: Auto close configured to 180s http: Checking phone is connected... debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (CONNECTING) debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (CONNECTING) debug: Registering onStateChange event debug: Emitting onInterfaceChange event (1 registered) http: Current state: SYNCING (SYNCING)

RAKESHSUVIDYA avatar Nov 11 '23 05:11 RAKESHSUVIDYA

Same here!

Divino67 avatar Feb 14 '24 13:02 Divino67

Hello, I'm having the same issue here that is will be only SYNCING (SYNCING) and it just hang there.

momokang avatar Feb 24 '24 06:02 momokang

Description

Hi, I'm working with multiple sessions, and I do have this code:

app.post('/whatsapp/session', function (req, res) { const id = randomUUID(); wppconnect .create({ session: id, catchQR: (base64Qr) => { sessions.push({ id, client: null, qr: base64Qr.split(',')[1], error: false, }); }, headless: true, // Headless chrome useChrome: false, // If false will use Chromium instance debug: true, // Opens a debug session logQR: true, // Logs QR automatically in terminal updatesLog: true, // Logs info updates automatically in terminal autoClose: 30000, // Automatically closes the wppconnect only when scanning the QR code (default 60 seconds, if you want to turn it off, assign 0 or false) tokenStore: 'file', // Define how work with tokens, that can be a custom interface })

When I make a POST request with Postman, it works fine the first time, but on the second one, it reuses the previous token folder. Evidence:" image image

"In the second image, the ID in the session is 'f0879c68-0d88-4d20-a301-4430b7056846,' and it is using the 'tokens' folder in the path 'tokens\9e56bf2c-6fc5-44b6-a7fb-b62e48daf720,'' which would be the ID of the first request made."

Environment

  • WPPConnect version(s): 1.28.0
  • Browser: Chrome
  • OS: Windows 10
  • Node version: Node 16.13.2
  • WhatsApp version: latest
  • MultiDevice (BETA): no

I had the same error, I fixed it by adding the folderNameToken parameter.

const wppClient = await create({
        session: props.session,
        deviceName: props.deviceName,
        poweredBy: props.poweredBy || "WPPConnect-Server",

        folderNameToken: `./tokens/${props.session}`,

        headless: true,
        useChrome: true,
        debug: false,
        logQR: false,
        browserArgs: [],

        onLoadingScreen: (percent, message) => { },
        catchQR: (base64Qr, asciiQR, attempt, urlCode) => { },
        statusFind: (statusFind) => { },
      }).then(async (client) => { });

rafatozzi avatar Apr 03 '24 16:04 rafatozzi

Please, update the project.

icleitoncosta avatar Jun 10 '24 02:06 icleitoncosta