Service to Service communication
Anonymous
TRIALOP

2 years ago

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.

0 Replies

Anonymous
TRIALOP

2 years ago

Project ID: 8899878e-7b5e-4ce3-9b68-7dfaf37583b9


jacobmacweb
TRIAL

2 years 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


jacobmacweb
TRIAL

2 years ago

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?


Anonymous
TRIALOP

2 years ago

Hey <@301736945610915852> 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)


jacobmacweb
TRIAL

2 years 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)



jacobmacweb
TRIAL

2 years ago

depending on your language / server, it should be relatively simple to change it


Anonymous
TRIALOP

2 years ago

ah great. will try that, too. let's see.


Anonymous
TRIALOP

2 years ago

<@301736945610915852> hmm starting my server listening on :: instead of 0.0.0.0 the healthchecks are failing 😦 I guess they need ipv4?


Anonymous
TRIALOP

2 years ago

I've to add that I'm deploying a docker container.


brody
EMPLOYEE

2 years 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


Anonymous
TRIALOP

2 years ago

Hey <@539512869780455445> thx for your answer. Your guess is right. This is fastapi and uvicorn.


brody
EMPLOYEE

2 years ago

try hypercorn instead, it supports dual stack binding unlike uvicorn.
example start command

hypercorn main:app --bind [::]:$PORT

Anonymous
TRIALOP

2 years ago

Thx <@539512869780455445> 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
EMPLOYEE

2 years ago

docker is a whole different ball game, you can't come into this with the "if it works locally" mindset


Anonymous
TRIALOP

2 years 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.


Loading...