R
Railway•9mo ago
demir7751

Service to Service communication

Hey there, I'm trying to establish a connection between two services. Service A does a request to service B on it's internal DNS (http://xxx.railway.internal:8080). Where 8080 is the port defined via variables. Service B is up and running and health checks work. However, In service A I'm getting a connection refused error. It's quite hard to debug afaik there's no solution to manually connect to the internal network via VPN or similar. Thx for the help.
14 Replies
Percy
Percy•9mo ago
Project ID: 8899878e-7b5e-4ce3-9b68-7dfaf37583b9
demir7751
demir7751OP•9mo ago
Project ID: 8899878e-7b5e-4ce3-9b68-7dfaf37583b9
stars
stars•9mo ago
I'm not sure if it's related, but is service B broadcasting on IPv6? Railways internal networking only works if the recepient service uses IPv6 I'm not sure the port is necessary though, I think the .internal domain just ties to the PORT railway provides. I suppose you could try remove the port?
demir7751
demir7751OP•9mo ago
Hey @stars thx for the reply. So B can handle ipv6 requests on that endpoint. Not sure what boradcasting means in this context. not very experienced with ipv6 yet. I can try to remove the port (request 80)
stars
stars•9mo ago
instead of hosting on 0.0.0.0 or 127.0.0.1, you should host on ::1 or maybe :: (see https://stackoverflow.com/questions/25817848/python-3-does-http-server-support-ipv6)
Stack Overflow
Python 3: Does http.server support ipv6?
Does http.server (http being a Python 3.x module) support ipv6? For instance, using this command-line code (which starts a webserver): python -m http.server [port]
stars
stars•9mo ago
Stack Overflow
What is IPV6 for localhost and 0.0.0.0?
As we all know the IPv4 address for localhost is 127.0.0.1 (loopback address). What is the IPv6 address for localhost and for 0.0.0.0 as I need to block some ad hosts.
stars
stars•9mo ago
depending on your language / server, it should be relatively simple to change it
demir7751
demir7751OP•9mo ago
ah great. will try that, too. let's see. @stars hmm starting my server listening on :: instead of 0.0.0.0 the healthchecks are failing 😦 I guess they need ipv4? I've to add that I'm deploying a docker container.
Brody
Brody•9mo ago
the healthcheck does indeed need your app to listen on ipv4, as does accessing the service publicly, and communicating via the private network requires your app to listen on ipv6, so your app must be capable of dual stack binding (ipv4 and ipv6) what kind of app is this? my first guess would be fastapi and uvicorn, since I know uvicorn doesn't support dual stack binding natively
demir7751
demir7751OP•9mo ago
Hey @Brody thx for your answer. Your guess is right. This is fastapi and uvicorn.
Brody
Brody•9mo ago
try hypercorn instead, it supports dual stack binding unlike uvicorn. example start command
hypercorn main:app --bind [::]:$PORT
hypercorn main:app --bind [::]:$PORT
demir7751
demir7751OP•9mo ago
Thx @Brody will try. It's a bit strange, though. Starting uvicorn with --host [::] I can locally curl with curl 0.0.0.0:8080 as well as curl '[::]:8080' in deployment it doesn't work.
Brody
Brody•9mo ago
docker is a whole different ball game, you can't come into this with the "if it works locally" mindset
demir7751
demir7751OP•9mo ago
So if anybody is interested: switching to hypercorn solved the networking issue but needed some change in the code base lifespan functionality. For now we've setup uvicorn to listen on :: and disabled the health check endpoint.
Want results from more Discord servers?
Add your server