Help Required to understand how to make my setup work with Railway
Hey!
I'm currently working on a setup involving multiple instances of Anvil, a CLI for running forked blockchains (more details at https://book.getfoundry.sh/anvil/), each running on a distinct port. These instances are initiated through a Dockerfile. Here's an outline of my setup and the challenge I'm facing:
Setup:
Primary Service: This contains a Dockerfile that initiates several Anvil instances. Each instance operates on a unique port (e.g., 8545, 8546, etc.).
Secondary Service: This service needs to interact with each Anvil instance through different URLs, such as:
http://someurl:8545
http://someurl:8546
and so forth...
Challenge:
I am struggling to understand how to effectively connect these services, particularly utilizing Railway's private networking capabilities or other potential solutions. My goal is to enable the secondary service to seamlessly communicate with each Anvil instance hosted by the primary service.
Could you provide guidance or suggestions on how to configure this setup correctly?
Any help or insights into this matter would be greatly appreciated. Thank you for your time and assistance!
Solution:Jump to solution
I think figured it out, I think I need to start anvil with
"anvil --host :: --port 8545"
Then when I run " netstat -ltp" I get
"tcp6 0 0 [::]:8545 [::]:* LISTEN 40679/anvil"...
48 Replies
Project ID:
c5efec47-1788-4144-9042-e3f0c9589053
c5efec47-1788-4144-9042-e3f0c9589053
wouldn't it just be as simple as replacing
someurl
with that services private domain?Railway only exposes one port per service, youβll need to create one service per CLI instance
Unless this isnβt the case for private networking
yeah I don't see why they couldn't use private networking for this
does private networking let you use multiple ports?
private networking lets you use anything
UDP, TCP, HTTP, any combination of those, any number of ports, anything
there's no proxy or firewall involved, you can think of it like connecting to another computer on the same network
@Brody, @Adam, thanks for taking the time to help. I have slightly adjusted my set up to be easier to work with. The Dockerfile spins up nginx (port 80) mapping
http://localhost/arbitrum1 -> port
http://localhost/arbitrum2 -> port
...
However, when I call e.g. http://anvils.railway.internal/arbitrum1 from inside the same environment, different service, it can't establish a connect. Do I use the private networking incorrectly?
the service(s) that you access over the private network need to listen on
::
aka all ipv6 addresses, since the private network is ipv6 onlyMhmm, ok, so I have to adjust my ngnix config to "listen [::]:80;", and then I can call the endpoint in the private environment with http://anvils.railway.internal/arbitrum1, or do I need to call the endpoint differently?
that's correct
but why does nginx come into play here? I thought you just wanted to call anvil on the different ports that it runs on from another service?
Before you guys responded I was searching for a different solution which would only require for port 80 to be exposed. I couldn't figure out the problem with the private networking. If I can figure out the private networking I will remove nginx again.
yeah you don't need nginx to map routes to ports since you are communicating over the private network
you can just make a request to the specific port on that service with the private network
assuming anvil is listening on
::
already, it really should be this simple@Brody, when I call "http://[::1]:8548" it works on my local machine, but not deployed on Railway for some reason. Do I have to somehow enable ipv6 when deploying inside the Dockerfile?
anvil is running in a different service, correct?
Yeah, so I have anvil-manager which calls "anvils" where the anvil instances run
then you need to use the private domain when calling your anvil service
keep this in mind
That's the domain, but when I call "http://anvils.railway.internal:8545/" from anvil manager it throws an error
what error
is anvil manager build with a dockerfile?
"TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11576:11)
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: Error: connect ECONNREFUSED fd12:379d:bc29::c9:7df1:7a24:8545
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: 'fd12:379d:bc29::c9:7df1:7a24',
port: 8545"
Yeah
just looks like anvil isnt listening on the ipv6 host
::
or not at port 8545it needs to listen on
::
not ::1
http://[::]:8545/ also works locally
doesnt mean its listening on
::
How can I check if it is "listening" on "::"?
its not working, so its not listening on
::
lol
either way, thats more so a question for anvil's docsI don't understand, sorry, I am not sure how to interact with stuff via ipv6, I haven't worked with ipv6 in this manner before. I don't know when I know that anvil is correctly listening to ipv6. How would http://[::]:8545/ look if it was correctly set up? What I have sent in the screenshot is a correct response
you should read their docs, look for a way to get anvil to listen on
::
I understand that you want me to look into the anvil docs, but I don't understand why you say "its not working, so its not listening on :: lol" How do you see that it is not correctly listening?
The connection was refused on Railway, so it is not properly listening on ::
Once you read the docs you'll find the configuration option to be able to set the url anvil is listening on
Once you set that to ::, it will work on Railway
again, that does not mean its listening on
::
Why? When do I know it is correctly listening to :: ? What is the way to check?
Rereading the thread, I notice you've changed the port from 80 to 8545, did you reflect this in Railway?
Did you change the PORT environment variable?
this is internal stuff, not needed
When do I know it is correctly listening to :: ? What is the way to check?when it works on railway!
Is ipv6 somethind that has to be enabled in the Dockerfile to work on Railway, some command?
Do you maybe have some example of a Dockerfile where it works?
no, again, its a config for anvil, you have to tell anvil to listen on
::
we are just going around in circles and ive just been repeating myself, please go read anvils docs so you can familiarize yourself with the technogies you are trying to useI understand anvil quite well. There is no specific option for ipv6, what I found in the docs is setting the port "anvil --port <PORT>" and "--host <ip>"
if anvil cant be properly configured to listen on
::
then you wont be able to talk to it over the private networkOk, I will play around with anvil further, and try to find a way to check if it listens to "::". If nothing works I will continue with my reverse proxy path
Thanks for the patience and time
Solution
I think figured it out, I think I need to start anvil with
"anvil --host :: --port 8545"
Then when I run " netstat -ltp" I get
"tcp6 0 0 [::]:8545 [::]:* LISTEN 40679/anvil"
Then it should work with Railway, right?
seems like it
Yep it works now!
I have learned something new
awesome