Search code examples
amazon-web-servicesnetwork-programmingamazon-ec2tcpamazon-elb

Connection to AWS Network ELB is either connecting right away or taking a long time to connect


I'm having an issue where a connection to AWS Network ELB is either connecting right away or taking a long time to connect. I checked through telnet from the Internet host and here is the output:

➜  ~ telnet host.elb.ap-northeast-1.amazonaws.com 8090
Trying 54.238.219.184...
telnet: connect to address 54.238.219.184: Operation timed out
Trying 35.74.146.43...
telnet: connect to address 35.74.146.43: Operation timed out
Trying 35.73.158.173...
Connected to host.elb.ap-northeast-1.amazonaws.com.
Escape character is '^]'.
^CConnection closed by foreign host.

Solution

  • Apparently the issue is caused by I set three subnets in the Availability Zones, and my Target EC2 is only in one zone. It seems Network ELB is performing some kind of round-robin mechanism between the generated three IP addresses for the Network ELB, and two of three subnets cannot reach the Target.

    The solution is to create a Network ELB with only one subnet/availability zone matching the subnet of the Target EC2.