3 months ago
I have an express app that uses the browser as a render engine. Puppeteer access the app's own endpoint, renders the content and evaluates the page as png through toDataUrl(). All good while running locally.
I saw that for Railway projects it's recommended to go with Browserless and so I changed to puppeteer-core and successfully connected with a Browserless v2 instance. The issue now comes from the fact that my browser isn't able to resolve the private network address. It throws:
Error: net::ERR_NAME_NOT_RESOLVED at http://<my-api>.railway.internal:<my-port>/<route>
at navigate (/src/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Frame.js:183:27)
at async Deferred.race (/src/node_modules/puppeteer-core/lib/cjs/puppeteer/util/Deferred.js:36:20)
at async CdpFrame.goto (/src/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Frame.js:149:25)
at async CdpPage.goto (/src/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:574:20)
I checked that the output for https:// didn't change and that fetching from a public domain such as https://www.google.com/ worked just fine.
At this point I ran out of ideas. I'd really like to avoid using a public domain since in my use case I won't ever be using browserless to fetch data outside my project.
12 Replies
3 months ago
Hello,
> The issue now comes from the fact that my browser isn't able to resolve the private network address
Are you trying to get your web browser to access the browserless instance?
If so, you should not be doing that; browserless should not be called from a user's web browser.
Best,
Brody
Status changed to Awaiting User Response Railway • 3 months ago
3 months ago
I'm trying to access an express api service using the browserless instance, both in the same project thus sharing the same network. Thanks for the fast reply!
Status changed to Awaiting Railway Response Railway • 3 months ago
Status changed to Awaiting User Response Railway • 3 months ago
3 months ago
yup. Since I need a server-side render engine and a browser does the work perfectly, I'm using browserless to give me access to the Canvas API. Using puppeteer I command the browserless instance to access my own service's page (thus drawing its content) and then I bake it into a PNG file. Normal fetching methods like returning json or xml don't work because they don't actually render anything.
Status changed to Awaiting Railway Response Railway • 3 months ago
3 months ago
Given the private network is IPv6 only, is your application and or Browserless setup to support doing a AAAA DNS lookup?
Status changed to Awaiting User Response Railway • 3 months ago
3 months ago
Thanks for the question. Did some inspection on the browserless shell and curl -v http://<my-api>.railway.internal/:<port>/<route>
successfully retrieved the page to my surprise. On the application side, running node -e "require('dns').promises.resolve6('<my-api>.railway.internal/:<port>/<route>').then(console.log).catch(console.error)"
also returned me the IPv6 address. Repeated the same command on the browserless shell and also successfully retrieved the application's IPv6 address.
Status changed to Awaiting Railway Response Railway • 3 months ago
3 months ago
Update: Hardcoding the ipv6 address caused browserless to successfully fetch the application's page without relying on outbound connections. Clearly not the optimal solution though. It seems the issue is indeed in the private DNS name.
3 months ago
Hard coding the IP is unfortunately not a solution at all, that IP is dynamic and will change with every single deployment.
You would have to investigate why you aren't able to have the code and or Browserless do its own AAAA lookup.
Status changed to Awaiting User Response Railway • 3 months ago
3 months ago
I've been trying to setup my clone of the browserless-v2 template (https://github.com/railwayapp-templates/browserless-v2) so I can add custom settings to the chromium launch. Even when moving the clone to the exact commit used in the deployment, the deployment oddly fails due to docker not finding the start*.sh files. I was already tired then so I'll be trying some more today. I'm guessing the additional security measures chromium has in comparison to chrome (what I was using with puppeteer before deploying to railway) may be related to the issue I'm facing.
Status changed to Awaiting Railway Response Railway • 3 months ago
3 months ago
I would have to say that you are likely going down the wrong rabbit hole there, but that's just my hunch.
Status changed to Awaiting User Response Railway • 3 months ago
brody
I would have to say that you are likely going down the wrong rabbit hole there, but that's just my hunch.
3 months ago
in regards to looking into chromium launching settings or something else?
Status changed to Awaiting Railway Response Railway • 3 months ago
3 months ago
Resolution:
I've forked the browserless-v2 template. After making sure my script/*.sh files used line feed instead of carriage return (SO issues), I added export CHROME_LAUNCH_ARGS="..."
with arguments related to security to my start_browserless.sh
file. Still some things to tune out but this thread seems to be solved. Thank you Brody for following me along. Cheers!
Status changed to Solved rubndev • 3 months ago