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:
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"...
Jump to solution
48 Replies
Percy
Percyβ€’12mo ago
Project ID: c5efec47-1788-4144-9042-e3f0c9589053
!0xRafael πŸ”¨πŸ‘·
c5efec47-1788-4144-9042-e3f0c9589053
Brody
Brodyβ€’12mo ago
wouldn't it just be as simple as replacing someurl with that services private domain?
Adam
Adamβ€’12mo ago
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
Brody
Brodyβ€’12mo ago
yeah I don't see why they couldn't use private networking for this
Adam
Adamβ€’12mo ago
does private networking let you use multiple ports?
Brody
Brodyβ€’12mo ago
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
!0xRafael πŸ”¨πŸ‘·
@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?
Brody
Brodyβ€’12mo ago
the service(s) that you access over the private network need to listen on :: aka all ipv6 addresses, since the private network is ipv6 only
!0xRafael πŸ”¨πŸ‘·
Mhmm, 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?
Brody
Brodyβ€’12mo ago
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?
!0xRafael πŸ”¨πŸ‘·
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.
Brody
Brodyβ€’12mo ago
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
!0xRafael πŸ”¨πŸ‘·
@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?
Brody
Brodyβ€’12mo ago
anvil is running in a different service, correct?
!0xRafael πŸ”¨πŸ‘·
Yeah, so I have anvil-manager which calls "anvils" where the anvil instances run
No description
Brody
Brodyβ€’12mo ago
then you need to use the private domain when calling your anvil service keep this in mind
!0xRafael πŸ”¨πŸ‘·
That's the domain, but when I call "http://anvils.railway.internal:8545/" from anvil manager it throws an error
Brody
Brodyβ€’12mo ago
what error is anvil manager build with a dockerfile?
!0xRafael πŸ”¨πŸ‘·
"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
Brody
Brodyβ€’12mo ago
just looks like anvil isnt listening on the ipv6 host :: or not at port 8545
!0xRafael πŸ”¨πŸ‘·
But when I build and run the image locally http://[::1]:8545/ works
Brody
Brodyβ€’12mo ago
it needs to listen on :: not ::1
!0xRafael πŸ”¨πŸ‘·
http://[::]:8545/ also works locally
Brody
Brodyβ€’12mo ago
doesnt mean its listening on ::
!0xRafael πŸ”¨πŸ‘·
How can I check if it is "listening" on "::"?
Brody
Brodyβ€’12mo ago
its not working, so its not listening on :: lol either way, thats more so a question for anvil's docs
!0xRafael πŸ”¨πŸ‘·
I 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
Brody
Brodyβ€’12mo ago
you should read their docs, look for a way to get anvil to listen on ::
!0xRafael πŸ”¨πŸ‘·
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?
Adam
Adamβ€’12mo ago
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
!0xRafael πŸ”¨πŸ‘·
Yeah, I understand, but it is working locally with "http://[::]:8545/ " with the same Dockerfile
Brody
Brodyβ€’12mo ago
again, that does not mean its listening on ::
!0xRafael πŸ”¨πŸ‘·
Why? When do I know it is correctly listening to :: ? What is the way to check?
Adam
Adamβ€’12mo ago
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?
Brody
Brodyβ€’12mo ago
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!
!0xRafael πŸ”¨πŸ‘·
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?
Brody
Brodyβ€’12mo ago
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 use
!0xRafael πŸ”¨πŸ‘·
I 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>"
Brody
Brodyβ€’12mo ago
if anvil cant be properly configured to listen on :: then you wont be able to talk to it over the private network
!0xRafael πŸ”¨πŸ‘·
Ok, 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
!0xRafael πŸ”¨πŸ‘·
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?
Brody
Brodyβ€’12mo ago
seems like it
!0xRafael πŸ”¨πŸ‘·
Yep it works now! I have learned something new
Brody
Brodyβ€’12mo ago
awesome
Want results from more Discord servers?
Add your server