3

I'm trying to communicate two services in Fargate, and when service A calls service B using the Route 53 name (not the IP) it says port 80: Connection refused.

In order to see what is going on I connected through SSH to an EC2 instance in the same vpc and everything works when I do the request using the private IP:port, but fails when I use the Route 53 name.

To me looks like I'm missing a step to either link the Route 53 name to the private IP:8080 instead of private IP:80 or, more likely, to redirect from port 80 to 8080 within the service B host.

Any idea on how to solve this?

Thanks!

Federico
  • 157
  • 1
  • 5
  • 23
  • So far it sounds like you're trying to communicate between ECS services without going over the internet. And from what you explained you want to do the ECS equivalent of docker links. Is that correct? I'm pretty sure that the docker link route won't work unless the containers are within the same task. https://stackoverflow.com/questions/34517265/linking-containers-between-task-definitions-in-aws-ecs – Jaron F Aug 11 '19 at 00:56
  • @JaronF Thanks for the link. The approved answer there says "ECS also has integration with Route 53 Auto Naming for DNS-based service discovery using A and SRV records. Your service's tasks can be automatically entered into and removed from DNS records." I want something like that, as for me would be important that both services work independently and don't need to be in the same host, so in the same task. – Federico Aug 11 '19 at 08:27

1 Answers1

3

Is service B running on port:8080? If so, then you might have to set that in the dns record type field when adding the service autodiscovery. Put your record type as srv & select either just the port or both the container and the port here. This should allow you to connect to service B.

Another way you could do this is by using a load balancer to your service. Now you can access the service B using the load balancer DNS and potentially use route53 to map the load balancer url to some domain you have. Since you can make a load balancer internal this can be entirely private.

Soccergods
  • 440
  • 5
  • 17
  • Hi @MasterFowl, thanks. I tried already adding the SRV record and then I can access service B as desired if I use , but this makes service A aware of the port (8080) in which service B runs. I would like to use just . – Federico Aug 17 '19 at 11:19
  • It doesn't look like there is a way to configure the port mapping in route 53. If you want to make a clean call (without the port) to the container, why not use a load balancer. Map the load balancer URL to a domain which you can create. You can then have a port which the load balancer is listening (80) and communicate with the task using some other port (8080). Also, do you have any idea which tasks your requests go to if you use service discovery on a service with multiple tasks? – Soccergods Aug 19 '19 at 17:58