Connect nest microservice use TCP
Hello everyone, is there a possibility today of using microservices via TCP using the Private Network?
like: https://docs.nestjs.com/microservices/basics
Documentation | NestJS - A progressive Node.js framework
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
24 Replies
Project ID:
664d04d5-be79-4adc-adff-e6aa3e8d9279
Project ID: 664d04d5-be79-4adc-adff-e6aa3e8d9279
tcp, udp, grpc, http, etc. its all supported on the private network, theres no proxys or firewalls involved, whatever your app exposes is what can be communicated with when using the private network. just bind to the
::
host and listen on a fixed port and you should be good.
read more here https://docs.railway.app/reference/private-networkingThanks so much for the feedback @Brody .. I appreciate it!
In my example I did this, however I am not getting the connection.
looks like you are trying to connect to the same container, use the internal dns name to connect to other services
When I change the dns to internal dns the error only changes but still doesn't find the connection
what is the error?
looks like you are still trying to connect to the same container
this is the point, the ip 3032 is from another container, I want to access it
I will share some more code information
3032 is a port, if you want to connect to that port on another service you need to use its private domain + that port
Exactly, however when setting the private domain on my host the error remains
your code is not trying to connect to another service with its private domain
thats because I've already changed it trying to fix it, I'll change it again and send you the error
Just to contextualize... I have two microservices
A: runs on port 8080 (http) and is configured on port 3030 (tcp)
B: runs on port 8082 (http) and is configured on port 3032 (tcp)
Microservice A
there we go, now we are getting somewhere
are you building your app with nixpacks?
no, i'm building with docker
railway runs everything on docker
do you mean you have written your own dockerfile?
exactly
whats the FROM image?
FROM node:lts-alpine as build-prd
Solution
right, in this case it would be setting this variable before execution. i try this approach here
it worked man!!! thank you very much for your attention and support... i really appreciate it!
no problem! happy to help