browserless (puppeteer) issues

eddietree
HOBBY

10 months ago

project id: 168b11d7-f1cd-4066-91c0-fd9530f55259

i have a headless puppeteer project and am trying to switch over to browserless (v2) having issues when swapping the code:

 //const browser = await puppeteer.launch({ headless: true });
    const browser = await puppeteer.connect({ browserWSEndpoint: process.env.BROWSER_WS_ENDPOINT });

received error on the puppeteeer.connect call:
'Unexpected server response: 404'

confirmed the BROWSERWSENDPOINT is correct (i even copied the wss: directly in case the env vars weren't passing thru)

0 Replies

eddietree
HOBBY

10 months ago

i followed the example here:
https://github.com/brody192/puppeteer-example

basically just replaced puppeteer.launch with connect, but seems to have issues

i had it running successfully with headless locally, but tried to convert to browserless to make it workable with railway, but getting this 404 error


eddietree
HOBBY

10 months ago

i tried running your example @Brody and having the same exact error "Unexpected server response: 404" on the puppeteer.connect call, using this simple example:

```const puppeteer = require('puppeteer');
const path = require('path');

var screenshotsDir = './temp';

async function run() {
const browser = await puppeteer.connect({ browserWSEndpoint: process.env.BROWSERWSENDPOINT }); // <---- crash here with "404" error
const page = await browser.newPage();
await page.goto("https://example.com/");
await page.screenshot({ path: path.join(screenshotsDir, 'screenshot.png') });
await browser.close();
}

run().catch(console.error);```


10 months ago

yep I am aware of the issue and will be fixing it when I'm back from PTO


eddietree
HOBBY

10 months ago

opps sorry to bother didnt know u were on PTO, when u get back?


10 months ago

this Friday, so I should be fixed saturday at the minimum


eddietree
HOBBY

10 months ago

great thank u, enjoy the rest of your pto


10 months ago

thank you!


10 months ago

@eddie - template has been fixed, please hard refresh your browser before you deploy the template again


eddietree
HOBBY

10 months ago

i am still getting 404, what dou mean by hard refresh? i tried redeploying


eddietree
HOBBY

10 months ago

i tried redeploying the Browserless app, is that what u mean?

1279859556385554400


10 months ago

you need to redeploy the template


10 months ago

not your pre existing deployment


eddietree
HOBBY

10 months ago

like create from scratch?


eddietree
HOBBY

10 months ago

ah okay gotcha


10 months ago

correct, delete that and deploy the template again


10 months ago

and a hard refresh is a key combo that refreshes the page without cache


eddietree
HOBBY

10 months ago

do i do v2 or v1?



10 months ago

up to you, v2 dropped support for selenium iirc


eddietree
HOBBY

10 months ago

thank u it worked! everything is good now <:thumbs:1235596472112644288>
appreciate your help


10 months ago

awsome!


10 months ago

i also have this for testing going forward

1279866023461519400


eddietree
HOBBY

10 months ago

this is awesome~


eddietree
HOBBY

10 months ago

dumb question -- how do i expose the railway URL of a project as an env variable? how does it know its own url?

how does browserless expose its own url as env var:
wss://[browserless-production-823f.up.railway.app](browserless-production-823f.up.railway.app)


10 months ago

not a dumb question, it uses the reference variable RAILWAY_PUBLIC_DOMAIN

you can view the raw editor to see how it's all pieced together.

docs here -


eddietree
HOBBY

10 months ago

perfect thank you!


eddietree
HOBBY

10 months ago

great service, as always. loyal customer since 2021 <:salute:1137099685417451530>

please close this thread, issue resolved


10 months ago

sounds good! happy to help 🙂