Skip to content

NLB Interfering with TCP

1

I have a very simple setup.

  • I have a ec2 instance with a minecraft service listening on 25565
  • I have added this ec2 instance to a target group
  • I have added this target group to a ipv4 NLB with a listener for TCP 25565
  • I have associated an elastic ip with this NLB

When I connect to the ec2 instance directly through public ip, everything works correctly. There is a TCP handshake, I can connect from client to minecraft server.

When I connect through the NLB, the connection doesn't appear to get through. The client can't ping much less connect to the ec2 instance server, and tcpdump on the server doesn't show incoming connections as expected.

More info:

  • the target group shows healthy
  • there are weights on the target group (ie not zero weighting)
  • security groups are set to allow tcp traffic for all ports from all locations for testing

Thanks for any ideas, I will post additional meta info upon request.

asked a year ago333 views

2 Answers
1

Hello.

Is the NLB running on a public subnet?
If the health check to the NLB is healthy, then the problem is probably with the NLB configuration, not EC2.
If the NLB is not placed in a public subnet, it will not be accessible even if you attach an Elastic IP.

EXPERT

answered a year ago

  • It has an "internet-facing" schema? I am using the default VPC and subnet for the region. MapPublicIpOnLaunch: true and the route table looks like it has an entry for a internet gateway

  • Is communication reaching the NLB from the client PC? You can try capturing packets on the client PC and see if there are any issues.

  • I can confirm the client sends the TCP packets correctly. There's no reason I can see that it would not reach a public facing NLB. I did find out that tcpdump shows NO incoming TCP connections when I switch from the EC2 public ip to the NLB elastic IP. This helps narrow it down, but I am stumped as to why the connection is being cut out at the NLB. All security groups are set to allow TCP for the port, and there is a listener on the NLB doing the same.

  • I attempted to fix the above issue by remaking the target groups to point to the IP of the instance instead of using the instance configuration. This did not seem to change anything.

0

Based on your description, there are several potential issues that could be preventing your Minecraft connections through the Network Load Balancer (NLB).

First, let's understand how NLB works with TCP connections. The NLB performs a TCP handshake with clients and then forwards traffic to your target EC2 instance. Since your target group shows healthy and you can connect directly to the EC2 instance, the core networking appears functional.

Here are some potential issues to check:

  1. Preserve Client IP Address: By default, NLB preserves client IP addresses. Make sure your EC2 instance's security group allows traffic from client IPs, not just from the NLB itself. Even though you mentioned security groups are open for testing, double-check this configuration.

  2. Routing Configuration: Ensure that the EC2 instance's routing table correctly routes return traffic. Since you can connect directly to the EC2, this is likely fine, but worth verifying.

  3. Health Check Configuration: While your target group shows healthy, verify that the health check is actually testing the Minecraft service on port 25565, not just checking if the instance is reachable.

  4. Cross-Zone Load Balancing: If your NLB is deployed across multiple Availability Zones, check if cross-zone load balancing is enabled. This could affect how traffic is distributed.

  5. Idle Timeout Settings: NLB has an idle timeout setting that might be affecting your connections. The NLB's idle timeout only tracks data transfer - it doesn't consider a TCP connection "idle" if there's no data flowing. This could potentially cause connection issues with Minecraft's protocol.

  6. TCP Keepalive Settings: You might need to adjust TCP keepalive settings on your EC2 instance to maintain connections through the NLB.

  7. Network ACLs: If you're using Network ACLs in your VPC, ensure they allow both inbound and outbound traffic on port 25565, as well as ephemeral ports for return traffic.

Since you can connect directly to the EC2 instance but not through the NLB, and tcpdump doesn't show incoming connections, it suggests the traffic isn't reaching your instance. This points to either an NLB configuration issue or a routing problem between the NLB and your instance.
Sources
Why is connection to NLB not closed after configured idle timeout? | AWS re:Post
What is the TCP handshake, and how does TCP/IP communication work? | AWS re:Post
Can't able to connect to the EC2 server in private network | AWS re:Post
Unable to connect to EC2 instance via https, although I can ping the instance via snmp | AWS re:Post

answered a year ago

AWS
EXPERT

reviewed a year ago

  • An update to address the Ai suggested issues:

    Preserve Client IP Address: 
       tested both on and off. currently off.  Does not see to materially affect this issue.
    Health Check Configuration: 
       yes it is pinging the service on the correct port
    Cross-Zone Load Balancing: not applicable
    Idle Timeout Settings: 
       maybe? default settings
    TCP Keepalive Settings: 
       maybe? default settings
    

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.