I have an application load balancer (ALB) and a number of web servers behind it. Apart from HTTP and HTTPS, the web servers also serve long-lasting TCP socket connections on port 52345.
When a client socket tries to connect to the ALB on port 52345, it fails, because ALB does not have a listener on this port.
When I tried to add a listener on this port, I realized that ALB only allows listeners on HTTP and HTTPS. So I tried to add a HTTP listener on port 52345. It still didn't work.
Error message:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 34.199.41.181:52345
How do I get over this hurdle? Why doesn't AWS allow TCP listener on ALB?
The ALB is specifically for http and https applications, not for general TCP. If you want a TCP load balancer you should consider using a NLB (Network Load Balancer). They scale to extremely high load and have some pretty useful features. The NLB can load balance any port including http/80 and https/443 but it's not application / protocol aware so it doesn't have capabilities such as path based routing. NLBs can have static (elastic) IPs.
If you need the capabilities of both types of load balancer you could consider using both. NLB could be on a subdomain or a fixed IP.