Unable to access Browserless service through private network
Hi, I have a Node.js API running in a service and a Browserless instance in another service. Both are in the same project and both are deployed from Docker images. I can't seem to get the private networking to work. Every time my API tries to connect to Browserless through the internal link, it errors out
Error: getaddrinfo ENOTFOUND browserless.railway.internal
. When using the public address for Browserless, it works fine. Any ideas what could be the issue?
Thanks
Project ID: 1cd9e13b-7e15-421e-9db9-c908c4e42e7e20 Replies
Project ID:
1cd9e13b-7e15-421e-9db9-c908c4e42e7e
Project ID:
1cd9e13b-7e15-421e-9db9-c908c4e42e7e
Private Networking takes 100ms to initialize, you'd need to add a bit of initial delay before trying to connect to the private network
3 seconds is a good amount
I believe that puppeteer (the library I'm using to connect to Browserless) has a 30second timeout by default, so that should be plenty. Can you think about anything else that could be the issue here?
Timeout != Delay
Could u try adding the
sleep 3 && ~your start command~
?Oh, so do you mean delay after the browserless service starts up? Sorry I meant that on every connection it needs the extra 100ms. I will try your solution, but I don't think this should be the issue then, because the service has been up for nearly an hour now. (Sorry if I'm not understanding something here)
Try it, we'll see.
Its a common issue with railway's private networking
delay before the browserless service starts
another question that might be worth asking, are you deploying your node api with nixpacks?
No, I'm not. I am using just my own Dockerfile to build the image. Tbh this is the first time I'm hearing about nixpacks.
does the dockerfile use an alpine image?
yes
give this docs section a read please https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images
🤦♂️🤦♂️ I actually read it, I just didn't think about it as I was so focused on the issue being somewhere in the Browserless deployment ... Thanks, I'll try adding the env var!
Interestingly enough, adding the env variable to Railway, crashed my startup command. I am using https://infisical.com/ to manage my env variables and that injects variables with the startup command like so
infisical run -- node server.js
. The error being "dial tcp: lookup app.infisical.com on [fd12::10]:53: dial udp [fd12::10]:53: connect: cannot assign requested address"you still need the delay like medium said
So I added the sleep, which fixed the issue with the startup of the node app, however the error with the connection still remains. One thing though, I added the sleep only to the node container as I'm not too sure what startup command to use with the browserless container.