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

sessions not working properly #1894

Open
joelvasiliev opened this issue Oct 25, 2023 · 10 comments
Open

sessions not working properly #1894

joelvasiliev opened this issue Oct 25, 2023 · 10 comments
Labels
bug Something isn't working needs triage

Comments

@joelvasiliev
Copy link

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 joelvasiliev added bug Something isn't working needs triage labels Oct 25, 2023
@icleitoncosta
Copy link
Contributor

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.

@nnkogift
Copy link

nnkogift commented Nov 4, 2023

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.

@RAKESHSUVIDYA
Copy link

device not connecting

@RAKESHSUVIDYA
Copy link

Session Unpaired

@RAKESHSUVIDYA
Copy link

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

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

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)

@Divino67
Copy link

Same here!

@momokang
Copy link

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

@rafatozzi
Copy link

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) => { });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

7 participants