a year ago
I'm trying to get private networking up and running for my react app. When setting an env variable, it doesn't seem to be registering.
project id: b3614c25-edc6-4752-b27d-9abc10f5adcf
125 Replies
a year ago
I don't understand javascript
a year ago
or private networking
a year ago
I have another service that should hit the api on startup, then close gracefully. It crashes

a year ago
fancy meeting you here
a year ago
what kind of react app?
a year ago
uhh
a year ago
website?
a year ago
I started with your template
a year ago
Okay, realizing I may be stupid and private networking won't work because it's a frontend
a year ago
But that doesn't explain why the environment variable isn't working
a year ago
Or why my other service can't hit the api
a year ago
depends, if it's vite, then the variable needs to be prefixed with VITE_ if it's create-react-app then the variable needs to be prefixed with REACT_APP_
a year ago
you might not be listening on IPv6? or you aren't specifying the port in the url, or both?
a year ago
Should be listening on IPv6?
a year ago

a year ago
Damn. I thought that was a weird convention, will put it back
a year ago
yep that should do it, what is the full url you are trying to call?
a year ago
that's fair tbh, it's tripped me up too
a year ago
do you have a PORT variable set to 5000?
a year ago
Yep
a year ago
okay, and is this gunicorn app in the same railway project?
a year ago
Oui
a year ago
okay, what exactly is trying to make the request? the fetch API from nodejs? fetch in a web browser?
a year ago
I'm not too familiar with js so don't know the specifics, but here's a code snippet

a year ago

a year ago
Just updated the var name
a year ago
Getting somewhere!

a year ago
If I have to use the public URL because of my implementation that's fine. It's not sending a ton of data
a year ago
oh so this is a request from the web browser?
a year ago
Yeah
a year ago
There's also a request from another python service that's not working
a year ago
From the screenshot up here
a year ago
if this is a browser trying to make the request, you need to use the public url
a year ago
Super simple code + some stackoverflow stuff that should force ipv6

a year ago
just do BACKEND_URL + "/setupCron"
and set the backend url to include the http:// and port part
a year ago
Testing that now
a year ago

a year ago
and that url leads to the app shown here?
a year ago
Yes
a year ago
and that app that is calling it, is in the same project right?
a year ago
Yep
a year ago
wait… what
a year ago

a year ago
Why does it print the full url earlier but not here
a year ago
there's no syntax difference between the two f strings
a year ago
lol python is fun
a year ago

a year ago

a year ago
What the hell
a year ago
remove that family stuff
a year ago
Just did, didn't work
a year ago
Gonna be honest here, I've literally never gotten the private network to work
a year ago
Now, a couple times was because I didn't know you couldn't call it from a react service, which makes total sense now that I think about it
a year ago
But it's just funky
a year ago
IPv6 can be tricky
a year ago
It should be ipv6 with the family stuff enabled, HAS_IPV6 is true
a year ago
Will keep looking into it
a year ago
I'll give your project a look over when I'm back at the laptop
a year ago
project id please
a year ago
b3614c25-edc6-4752-b27d-9abc10f5adcf
a year ago

a year ago
i lied
a year ago
you forgot --bind
a year ago
ah shit
a year ago
my bad
a year ago
You're good I'm the one who forgor
a year ago
this is returned in an api call the dashboard makes, wish it was made visible in the product for the user to see somehow
a year ago
It worked! Thanks for helping fix such a stupid mistake lol
a year ago
I have a ticket to track how many times I have to look at sockets.ipv6 lol
a year ago
hopefully if it gets enough traction the information can be exposed to the end user
a year ago
Yeah that'd be very nice. At least as a warning near the private url
a year ago
it gets a little tricky since a service can listen on multiple ports
a year ago
I thought that the proxy sends all requests to one port?
a year ago
yeah the public proxy, but we are talking about the private network
a year ago
Ah I figured that it worked much the same
a year ago
nope, no proxy internally
a year ago
There are decent docs on how to use it, but no specifics about how it actually works in comparison to the public network
a year ago
just works like a local area network, with a nice domain and IPv6 only
a year ago
So all services effectively just take different ports within the .railway.internal host? I'm assuming that two services can't have the same port then
a year ago
Not sure if that's documented
a year ago
two services can have the same port, services listen on whatever port they listen on and are accessible on whatever port they do listen on
a year ago
literally think of it as a LAN network
a year ago
So if two services have the same port, they'll both recieve requests meant for the other?
a year ago
I'm not sure what the LAN behaviour for that is lol
a year ago
no, they will receive the traffic that is destined to them
a year ago
internally your app does a DNS lookup, gets the IP and then sends the traffic to that IP and port
a year ago
Will they not both be assigned HOSTNAME:5000 (for example) if they both have the same port?
a year ago
they are separate services though
a year ago
How does the origin know which service to send to?
a year ago
Right, but they share a port
a year ago
so? they have different IPs
a year ago
If the only point of reference is the port number, I don't see how the IP comes into play
a year ago
are we talking about traffic coming in publicly or privately?
a year ago
privately
a year ago
If service A wants to send to service B, but service B shares a port with service C. Service A sends a request to HOSTNAME:PORT
a year ago
then it does a DNS lookup for the host, gets its IP, and then sends the data to that IP + port, each service has its own IP
a year ago
But how would it know which service to send to, there's no identifier that would tell one from the other
a year ago
the IP is the identifier
a year ago
I get that each service has its own IP, but if both are listening on HOSTNAME:PORT how does the origin's code know which IP to send to
a year ago
whatever IP was returned from the DNS lookup
a year ago
That's not answering my question
a year ago
Let's say we have 3 services. Two are listening on project.railway.internal:5000. The third sends a request to project.railway.internal:5000
a year ago
Which service does the third send the request to
a year ago
I'm not understanding how the issue of two services sharing a port is resolved
a year ago
you just gave me the same 3 domains?
a year ago
I did, two are listening on the same port on the private network
a year ago
you can't have the same domains
a year ago
domains need to be unique per environment
a year ago
So two services on the private network cannot listen on the same port?
a year ago
they can listen on the same ports, they just can't have the same domain
a year ago
But will their hostname not be the same? I thought that was unique per project
a year ago
Assuming two services in the same project
a year ago
no, every service in an environment will have a unique domain
a year ago
Ah there we go that's what I was missing
a year ago
I mean it's the same for the public network
a year ago
I made an assumption based on the private network hostname for the backend api we worked out last night

a year ago
my bad
a year ago
two people can't own google.ca at the same time, legal reasons aside
a year ago
lol right
a year ago
looks like you changed the service name and left the private domain as it was originally
a year ago
you would not be able to make another service with the same private domain, it would get a different domain
a year ago
Makes sense
a year ago
feel free to mark as solved if you dont have anymore questions 🙂
a year ago
!s
Status changed to Solved adam • about 1 year ago