Browserless only listening to 127.0.0.1?

stauersbol
PRO

a year ago

Hello,

I'm trying to use browserless for my playwright testing…
But it never connects, I tried adding proxy environment but that didn't change anything…

What can I do?

Project id: 8692a59f-3cb6-4863-a67e-c9864cb63401

0 Replies

stauersbol
PRO

a year ago

ARG VERSION=latest
FROM browserless/chrome:$VERSION

ENV PROXY_HOST="browserless-production-ae10.up.railway.app"
ENV PROXY_PORT=$PORT
ENV PROXY_SSL=true

This is what I did to try and make it work, but I just hit a wall, please note these ENV are per browserless's documentation


stauersbol
PRO

a year ago

I took a look on the /sessions page to see what endpoint it was using and it uses:

{
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=0.0.0.0:7690/devtools/page/6787140A97C09B8BF27082D8FB527EF1",
"id": "6787140A97C09B8BF27082D8FB527EF1",
"title": "about:blank",
"type": "page",
"url": "about:blank",
"webSocketDebuggerUrl": "ws://0.0.0.0:7690/devtools/page/6787140A97C09B8BF27082D8FB527EF1",
"port": "44335",
"browserId": "3c935235-a887-4336-9b19-43c9c4f19de0",
"trackingId": null,
"browserWSEndpoint": "ws://0.0.0.0:7690/devtools/browser/3c935235-a887-4336-9b19-43c9c4f19de0"
},

stauersbol
PRO

a year ago

Plus I am getting this also


stauersbol
PRO

a year ago

I'm gonna try adding the env vars to the project specifically instead inside of the Dockerfile


a year ago

you would need to get browserless to listen on :: or [::] aka ipv6

then you'd want to use it's private domain to connect to it from other services while on railway


stauersbol
PRO

a year ago

Would I need to specific that as a HOST env?


a year ago

unfortunately I am uncertain on how you would configure what host browserless runs on


a year ago

for that, you would need to reference their documentation


stauersbol
PRO

a year ago

Alright


stauersbol
PRO

a year ago

Seems like it is just HOST as an environment variable


a year ago

I assume you are using the browserless template?


stauersbol
PRO

a year ago

Uh yes


stauersbol
PRO

a year ago

Well I had to redeploy, but yes


a year ago

that template is very old and thus made long before railway had private networking


a year ago

you are not the first to have issues using it


stauersbol
PRO

a year ago

Yes, but it uses the latest docker image


a year ago

yes, but it's missing the correct configurations to use it


a year ago

in fact it's so old, it deploys from a Dockerfile when it should be just a docker image without a github repository


stauersbol
PRO

a year ago

[ghcr.io/browserless/base:latest](ghcr.io/browserless/base:latest) something like this?


stauersbol
PRO

a year ago

I'll see if it works now


a year ago

I don't know, did they stop hosting their images on dockerhub?


stauersbol
PRO

a year ago

They still are


stauersbol
PRO

a year ago

but they are also hosting on the github reg


a year ago

any reason you decided to switch to the ghcr hosted image?


a year ago

along with going for the base image and not the chrome image


stauersbol
PRO

a year ago

oh I didn't I just sent what I saw on the ghcr



stauersbol
PRO

a year ago

still on dockerhub


stauersbol
PRO

a year ago

okay I switched from the template to the docker image directly


a year ago

looks like you where correct about the HOST variable


stauersbol
PRO

a year ago

Looks like it is not possible to supply "::" as a host value


stauersbol
PRO

a year ago

here is the logs


stauersbol
PRO

a year ago

just so you can see


a year ago

have you tried the other host option I mentioned? [::]


stauersbol
PRO

a year ago

uhh let me try


stauersbol
PRO

a year ago


stauersbol
PRO

a year ago

using [::]


a year ago

interesting, though that is more progress


a year ago

wonder why it's trying to do a DNS lookup on its own host?


stauersbol
PRO

a year ago

yeah very good question… though it seems like some internal thing?


a year ago

it needs to not do that lol


a year ago

have you tried 0.0.0.0 as the HOST?


stauersbol
PRO

a year ago

that is the default, but I will try and swap it to that


a year ago

I thought 127.0.0.1 was the default, as your title says


stauersbol
PRO

a year ago

well it looks like i was using v1 of browserless(which is what the template is using)


stauersbol
PRO

a year ago

and after swapping to using the docker image directly


stauersbol
PRO

a year ago

it swapped to v2


a year ago

interesting, does this mean it works now?


stauersbol
PRO

a year ago

logs now using default


a year ago

okay good sign, no errors


stauersbol
PRO

a year ago

other thing they also did was make a separate image for chormium


stauersbol
PRO

a year ago

I was using the chrome image, which could also be why it does not connect


a year ago

why would chrome Vs chromium cause it not to connect?


stauersbol
PRO

a year ago

idk just reading the docs on the service said to swap it to use [ghcr.io/browserless/chromium](ghcr.io/browserless/chromium)


stauersbol
PRO

a year ago

instead of [ghcr.io/browserless/chrome](ghcr.io/browserless/chrome)


stauersbol
PRO

a year ago

idk what difference it makes


a year ago

have you tried to connect to it yet?


stauersbol
PRO

a year ago

yes


stauersbol
PRO

a year ago

when I used the chrome specific image


stauersbol
PRO

a year ago

and it still didn't work


a year ago

what is the url you are trying to connect to it with?


stauersbol
PRO

a year ago

so swapped to chromium image to see if that was the cause


stauersbol
PRO

a year ago

ws://[browserless-production-9cdd.up.railway.app/playwright/chromium](browserless-production-9cdd.up.railway.app/playwright/chromium) as an external right now


a year ago

you need to use wss


stauersbol
PRO

a year ago

ah yeah


a year ago

railway is ssl only


stauersbol
PRO

a year ago

With connection tries


a year ago

what is the url you are trying to connect to it with?


stauersbol
PRO

a year ago

wss://[browserless-production-9cdd.up.railway.app/chromium/playwright](browserless-production-9cdd.up.railway.app/chromium/playwright)


stauersbol
PRO

a year ago

please note


stauersbol
PRO

a year ago


stauersbol
PRO

a year ago

docs says it can take either way of that URL


stauersbol
PRO

a year ago

could "PORT" be the issue here?


stauersbol
PRO

a year ago

as I had it set to 3000


a year ago

is that not the port browserless runs on?


stauersbol
PRO

a year ago

uhh you can change it


stauersbol
PRO

a year ago

with a env var


a year ago

right but what's the default port browserless runs on


stauersbol
PRO

a year ago

default is 3000


stauersbol
PRO

a year ago

since I have set a external URL I can simply just try and connect to it with the generated URL


a year ago

your url is incorrect, it was changed in v2 according to their migration guide

it should be /playwright/chromium


stauersbol
PRO

a year ago


stauersbol
PRO

a year ago

still says it can't see it


stauersbol
PRO

a year ago

I'm gonna try with connectOverCDP


a year ago

what's cdp?


stauersbol
PRO

a year ago

no


a year ago

sorry, typo


stauersbol
PRO

a year ago

const browser = await pw.chromium.connect('ws://localhost:3000/playwright/chromium');

// OR
const browser = await pw.chromium.connectOverCDP('ws://localhost:3000');

stauersbol
PRO

a year ago

what the docs gives


stauersbol
PRO

a year ago

ignoring ws as that should be wss


a year ago

can't hurt to try


stauersbol
PRO

a year ago

well that did nothing


stauersbol
PRO

a year ago

as in no logs or anything


a year ago

was worth a try


stauersbol
PRO

a year ago

yeah idk why it keep saying it couldn't get that URL…


a year ago

are you specifying a token?


stauersbol
PRO

a year ago

nope


a year ago

try doing so


stauersbol
PRO

a year ago


stauersbol
PRO

a year ago

with token


stauersbol
PRO

a year ago

I'm at a loss of how to fix this


a year ago

im trying some things, but i am going to leave the house soon so im not sure how much i will be able to get done


stauersbol
PRO

a year ago

yeah that is alright, no rush on this


a year ago

im not seeing how this is a limitation of railway, very likely just have some minor config wrong


stauersbol
PRO

a year ago

yeah, its just odd


a year ago

indeed


stauersbol
PRO

a year ago

Funny.

I just tried running a websocket connect in Insomnium and it gets a 400…


a year ago

what happens when you just open the /docs endpoint in your browser


stauersbol
PRO

a year ago

This


stauersbol
PRO

a year ago

I've been on it for a good while now


a year ago

okay that at least works


stauersbol
PRO

a year ago

I tried not having any proxy/external set as a env var as I had before


stauersbol
PRO

a year ago

and I can still access this site without any issues


stauersbol
PRO

a year ago

It's just so odd playwright wants to try and use some HTTP request?


stauersbol
PRO

a year ago

and not just go straight to using websocket..


a year ago

works fine for me


stauersbol
PRO

a year ago

hmm……..


a year ago

show me all your variables as shown in the raw editor


stauersbol
PRO

a year ago


a year ago

here are mine

HOST=0.0.0.0
PORT=3000
PROXY_HOST=${{RAILWAY_PUBLIC_DOMAIN}}
PROXY_PORT=443
PROXY_SSL=true
TOKEN=ShMC4aK5RjYQtWdpTBU9bDeX3g2xE6sf

and my url used in my code looks like wss:///playwright/chromium?token=


stauersbol
PRO

a year ago

Okay let me try that out


stauersbol
PRO

a year ago

are you using the docker image directly?


stauersbol
PRO

a year ago

or the template


a year ago

and remind me again, what is the current image you are using? im using [ghcr.io/browserless/chromium:latest](ghcr.io/browserless/chromium:latest)


stauersbol
PRO

a year ago

that is the same as mine


a year ago

i deployed all this from scratch


stauersbol
PRO

a year ago


a year ago

not that it would technically matter since at this point you are using the same image as me


stauersbol
PRO

a year ago


stauersbol
PRO

a year ago

I can do a full redeploy


stauersbol
PRO

a year ago

and see what that does


a year ago

show me your raw variables?


stauersbol
PRO

a year ago


stauersbol
PRO

a year ago

I did a redeploy with using the ghcr image link you sent


stauersbol
PRO

a year ago

Just wondering if there would be a difference between these 2


a year ago

for all intensive purposes, not specifying the :latest tag should be the same as specifying the :latest tag, but can't hurt to try


stauersbol
PRO

a year ago

no difference


stauersbol
PRO

a year ago

HOST=0.0.0.0
PORT=3000
PROXY_HOST=${{RAILWAY_PUBLIC_DOMAIN}}
PROXY_PORT=443
PROXY_SSL=true
TOKEN=test123

a year ago

show me your code?


stauersbol
PRO

a year ago

I'm using bun, but I don't think that should make an awful lot of a difference


a year ago

oh bun, who knows, i've seen bun do some funky stuff


a year ago

its still javascript so lets see the code anyway


stauersbol
PRO

a year ago

import { type ModalSubmitInteraction } from "discord.js";
import { type Browser, chromium, type Page } from "playwright";
const pw = require("playwright");
import { addArt } from "./utils/directus";

export const submitArt = async (
  interaction: ModalSubmitInteraction,
  link: string,
) => {
  await interaction.reply({
    ephemeral: true,
    content: "Submitting art...",
  });

  const browser = await pw.chromium.connect(
    "wss://browserless-production-9cdd.up.railway.app/playwright/chromium?token=test123",
  );

  try {
    const page = await browser.newPage();

    await page.goto(link);
    await page.waitForSelector("section");

    if (!submitted) {
      await interaction.editReply({
        content: "Couldn't submit art to website, please ask for help.",
      });

      await browser.close();
      return;
    }

    await browser.close();

    await interaction.editReply({
      content: "Art successfully submitted!",
    });
  } catch (error) {
    console.error(error);
    await browser.close();

    await interaction.editReply({
      content:
        "Failed to submit art. Please try again, and if it fails again then report the issue.",
    });
  }
};

stauersbol
PRO

a year ago

Pretty much how it stands right now


stauersbol
PRO

a year ago

Don't mind the top require one, I was just seeing if import and require had some quirky difference


stauersbol
PRO

a year ago

but still same behaviour


a year ago

would you be interested in trying their example code with node instead of bun?


a year ago

always good to first get a minimal example working!


stauersbol
PRO

a year ago

yeah let me spin up a minimal project then


stauersbol
PRO

a year ago

huh…


stauersbol
PRO

a year ago

that worked?


a year ago

okay now run the same example code on bun?


stauersbol
PRO

a year ago

ahaaa


stauersbol
PRO

a year ago

<:ICANT:1010977143771111434>


stauersbol
PRO

a year ago

so Bun just hangs when it tries to connect


stauersbol
PRO

a year ago

while node does not


stauersbol
PRO

a year ago

interesting…


stauersbol
PRO

a year ago


a year ago

thats running the same example code with bun?


stauersbol
PRO

a year ago

guess that is a bun thing then


stauersbol
PRO

a year ago

yes


stauersbol
PRO

a year ago

and its just hanging


stauersbol
PRO

a year ago

so this is a bun quirk


a year ago

alrightly bun issue then


a year ago

how fun


stauersbol
PRO

a year ago

Just really pain for me


stauersbol
PRO

a year ago

as I don't want to rewrite my whole project


a year ago

you use bun apis?


stauersbol
PRO

a year ago

Nope


stauersbol
PRO

a year ago

None


stauersbol
PRO

a year ago

besides bun run --watch


stauersbol
PRO

a year ago

which is only locally


a year ago

so then why would a rewrite be needed? just switch to node?


stauersbol
PRO

a year ago

the production code is just running node dist/index.js


stauersbol
PRO

a year ago

as I'm using tsup to compile(transpile) to js


stauersbol
PRO

a year ago

right okay then its just something for local


stauersbol
PRO

a year ago

good to know


stauersbol
PRO

a year ago

  if (process.env.NODE_ENV === "production") {
    browser = await chromium.connect(
      "wss://browserless-production-9cdd.up.railway.app/playwright/chromium?token=test123",
    );
  } else {
    browser = await chromium.launch();
  }

stauersbol
PRO

a year ago

I had it like this before


stauersbol
PRO

a year ago

and I wanted to test browserless locally with bun


stauersbol
PRO

a year ago

which then caused this mess


stauersbol
PRO

a year ago

oh well


a year ago

well problem solved though!


stauersbol
PRO

a year ago

yes!


stauersbol
PRO

a year ago

thank you for sticking with me 😂


stauersbol
PRO

a year ago

and spending so much time on this


a year ago

happy to help!


a year ago

problem solved, and now you also have a v2 browserless deploy that can be used with node


stauersbol
PRO

a year ago

Yes


stauersbol
PRO

a year ago

the production command is node dist/index.js


stauersbol
PRO

a year ago

so it doesn't rely on bun


a year ago

time to change that token too!


stauersbol
PRO

a year ago

ah yes true


stauersbol
PRO

a year ago

feel free to close this issue now


stauersbol
PRO

a year ago

I can't mark it as solved somehow


a year ago

that seems like a good message to mark as solved haha