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
Percy
Percy13mo ago
Project ID: 664d04d5-be79-4adc-adff-e6aa3e8d9279
alexandesigner
alexandesignerOP13mo ago
Project ID: 664d04d5-be79-4adc-adff-e6aa3e8d9279
Brody
Brody13mo ago
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-networking
alexandesigner
alexandesignerOP13mo ago
Thanks so much for the feedback @Brody .. I appreciate it! In my example I did this, however I am not getting the connection.
No description
No description
Brody
Brody13mo ago
looks like you are trying to connect to the same container, use the internal dns name to connect to other services
alexandesigner
alexandesignerOP13mo ago
When I change the dns to internal dns the error only changes but still doesn't find the connection
Brody
Brody13mo ago
what is the error?
alexandesigner
alexandesignerOP13mo ago
No description
Brody
Brody13mo ago
looks like you are still trying to connect to the same container
alexandesigner
alexandesignerOP13mo ago
this is the point, the ip 3032 is from another container, I want to access it I will share some more code information
Brody
Brody13mo ago
3032 is a port, if you want to connect to that port on another service you need to use its private domain + that port
alexandesigner
alexandesignerOP13mo ago
Exactly, however when setting the private domain on my host the error remains
Brody
Brody13mo ago
your code is not trying to connect to another service with its private domain
alexandesigner
alexandesignerOP13mo ago
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)
alexandesigner
alexandesignerOP13mo ago
Microservice A
No description
Brody
Brody13mo ago
there we go, now we are getting somewhere are you building your app with nixpacks?
alexandesigner
alexandesignerOP13mo ago
no, i'm building with docker
Brody
Brody13mo ago
railway runs everything on docker do you mean you have written your own dockerfile?
alexandesigner
alexandesignerOP13mo ago
exactly
Brody
Brody13mo ago
whats the FROM image?
alexandesigner
alexandesignerOP13mo ago
FROM node:lts-alpine as build-prd
alexandesigner
alexandesignerOP13mo ago
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!
Brody
Brody13mo ago
no problem! happy to help
Want results from more Discord servers?
Add your server