You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Solved by not using the express middleware, but I guess there's still something wrong with it. Solution is just calling Puppeteer.use(PortalPlugin) like the second example in the readme, using a different port than express uses.
If someone could help on this, I wanted to remove the 'reload' button from the page because it breaks things on my app so it needs to restart. but commenting out everything to do with reload in index.bundle and removing the reload div in index.html doesn't remove it. Weird since I thought the index.html is what is actually loaded. Any way to remove the button?
Using Node 20.x Windows 11 USING AS EXPRESS MIDDLEWARE
I configured portal to open after I initialize a page, but after properly configuring it (I guess), weirdly all it shows to me is a reload button, and the text "Session complete! Browser has closed. Session complete". I don't know why the websocket connection fails.
Note: I had to write app.use(PortalPlugin().createExpressMiddleware()); instead of app.use(PortalPlugin.createExpressMiddleware()); (like the docs here says)
because it wouldn't run otherwise.
I tried using localhost and 127.0.0.1, both return the same thing. The puppeteer page is running normally and headless (it's a web.whatsapp page) .
The only thing that appears in the web console is this error:
And logs this object if I restart the page: (then the error above right after)
Server start code:
app.use(PortalPlugin().createExpressMiddleware());constserver=app.listen(process.env.PORT,()=>{logger.info(`Servidor iniciado na porta: ${process.env.PORT}`);});server.headersTimeout=0;// Required for Node 18+ due to slow loris attack changeserver.requestTimeout=0;initIO(server);StartAllWhatsAppsSessions();// <------ puppeteer and portal are started heregracefulShutdown(server);
puppeteer client code
constpuppeteer=require("puppeteer-extra");// Add stealth plugin and use defaults (all tricks to hide puppeteer usage)constStealthPlugin=require("puppeteer-extra-plugin-stealth");puppeteer.use(StealthPlugin());// TRIED DISABLING THIS, SAME PROBLEM OCCURS -----------// add portal pluginconstPortalPlugin=require('puppeteer-extra-plugin-portal');puppeteer.use(PortalPlugin({webPortalConfig: {// When used as middleware, you'll need to provide the baseUrl if it's anything but http://localhost:3000baseUrl: "http://127.0.0.1:8080",},}))// .... unrelated code here .....asyncinitialize(){let[browser,page]=[null,null];awaitthis.authStrategy.beforeBrowserInitialized();constpuppeteerOpts=this.options.puppeteer;if(puppeteerOpts&&puppeteerOpts.browserWSEndpoint){browser=awaitpuppeteer.connect(puppeteerOpts);page=awaitbrowser.newPage();}else{constbrowserArgs=[...(puppeteerOpts.args||[])];if(!browserArgs.find((arg)=>arg.includes("--user-agent"))){browserArgs.push(`--user-agent=${this.options.userAgent}`);}browser=awaitpuppeteer.launch({ ...puppeteerOpts,args: browserArgs});page=(awaitbrowser.pages())[0];if(this.options.proxyAuthentication!==undefined){awaitpage.authenticate(this.options.proxyAuthentication);}awaitpage.setUserAgent(this.options.userAgent);if(this.options.bypassCSP)awaitpage.setBypassCSP(true);this.pupBrowser=browser;this.pupPage=page;awaitthis.authStrategy.afterBrowserInitialized();awaitthis.initWebVersionCache();awaitpage.goto(WhatsWebURL,{waitUntil: "load",timeout: 0,referer: "https://whatsapp.com/",});// Open a portal to get a link to it. constportalUrl=awaitpage.openPortal();// <-------------------------- OPEN PORTAL ----------------------console.log('Portal URL:',portalUrl);}
More info
This project uses socket.io in "initIO(server);". Maybe this has something to do with portal's websocket failing? I believe the problem here is in the express middleware, but I have no idea what to look for or where. 😢
The text was updated successfully, but these errors were encountered:
gkp1
changed the title
Portal only shows "Session complete! Browser has closed. Session complete"
WebSocket connection fails, "Session complete! Browser has closed. Session complete"
Dec 28, 2023
gkp1
changed the title
WebSocket connection fails, "Session complete! Browser has closed. Session complete"
WebSocket connection fails
Dec 28, 2023
gkp1
changed the title
WebSocket connection fails
WebSocket connection fails (Express middleware)
Dec 29, 2023
Edit: solved
Solved by not using the express middleware, but I guess there's still something wrong with it. Solution is just calling Puppeteer.use(PortalPlugin) like the second example in the readme, using a different port than express uses.
If someone could help on this, I wanted to remove the 'reload' button from the page because it breaks things on my app so it needs to restart. but commenting out everything to do with reload in index.bundle and removing the reload div in index.html doesn't remove it. Weird since I thought the index.html is what is actually loaded. Any way to remove the button?
Using Node 20.x Windows 11 USING AS EXPRESS MIDDLEWARE
I configured portal to open after I initialize a page, but after properly configuring it (I guess), weirdly all it shows to me is a reload button, and the text
"Session complete! Browser has closed. Session complete"
. I don't know why the websocket connection fails.Note: I had to write
app.use(PortalPlugin().createExpressMiddleware());
instead ofapp.use(PortalPlugin.createExpressMiddleware());
(like the docs here says)because it wouldn't run otherwise.
I tried using localhost and 127.0.0.1, both return the same thing. The puppeteer page is running normally and headless (it's a web.whatsapp page) .
The only thing that appears in the web console is this error:
And logs this object if I restart the page: (then the error above right after)
Server start code:
puppeteer client code
More info
This project uses socket.io in "initIO(server);". Maybe this has something to do with portal's websocket failing? I believe the problem here is in the express middleware, but I have no idea what to look for or where. 😢
The text was updated successfully, but these errors were encountered: