Proper Connecting String Syntax for Private Services

I must be going insane. Whats the right connection string format to connect to a private service in a Railway network? I've tried:
service
service.railway.internal
service.railway.internal/graphql
service.railway.internal:port/graphql
http://service.railway.internal/graphql
https://service.railway.internal/graphql
http://service.railway.internal:port/graphql
https://service.railway.internal:port/graphql

service
service.railway.internal
service.railway.internal/graphql
service.railway.internal:port/graphql
http://service.railway.internal/graphql
https://service.railway.internal/graphql
http://service.railway.internal:port/graphql
https://service.railway.internal:port/graphql

I am attempting to call a graphql endpoint in one Node service from another using fetch.
const fetchGQL = async (query, variables) => {
try {
const res = await fetch(API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: query,
variables: variables,
}),
});
const obj = await res.json();
return obj.data;
} catch (err) {
logger.error({ error: err }, 'GraphQL fetch failed.');
}
};

const res = fetchGQL(query, vars);

res = undefined

API_URL = each of the above
const fetchGQL = async (query, variables) => {
try {
const res = await fetch(API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: query,
variables: variables,
}),
});
const obj = await res.json();
return obj.data;
} catch (err) {
logger.error({ error: err }, 'GraphQL fetch failed.');
}
};

const res = fetchGQL(query, vars);

res = undefined

API_URL = each of the above
The service I am attempting to connect to is running on port 7653. I know this because I have it log process.env.PORT on start.
10 Replies
Percy
Percy10mo ago
Project ID: db989257-d5bb-4cba-acd6-bc0aa22606a5
bigviking
bigviking10mo ago
db989257-d5bb-4cba-acd6-bc0aa22606a5 Public API for the service works. I can query it from Postman. << Hold off on responding to this just working something out >> OK after another few hours I must be not understanding how to access services via private endpoints from within the network. When using the service's public address I have no problems whatsoever. After some more reading I came across this.
You will need to bind to a IPv6 port to receive traffic on the private network.
You will need to bind to a IPv6 port to receive traffic on the private network.
How would I implement this in an express application so another app can privately talk to it? I had to do this in my Express app. And now it can accept IPv6 connections. Someone should add this to your docs. It took me hours for something really simple (beginner).
const hostname = '::';

// http server start
httpServer.listen(PORT, hostname, () => {
logger.info(
`Apollo/GraphQL websocket service is live on endpoint: ${PORT}/graphql`
);
});
const hostname = '::';

// http server start
httpServer.listen(PORT, hostname, () => {
logger.info(
`Apollo/GraphQL websocket service is live on endpoint: ${PORT}/graphql`
);
});
Brody
Brody10mo ago
but whats not in the docs, is that you will want to set a static PORT service variable and then listen on that variable
bigviking
bigviking10mo ago
Oh for .... lfg could have sworn I read that page a half dozen times
Brody
Brody10mo ago
use the search bar lol
bigviking
bigviking10mo ago
Its late..
Brody
Brody10mo ago
fair enough
bigviking
bigviking10mo ago
Thank you sir.
Brody
Brody10mo ago
no problem!
Want results from more Discord servers?
Add your server