Gamelift Managed Containers same UDP and TCP port

0

Hello!

I am facing an issue connecting to gamelift managed containers after the game session is created on the fleet.

Both of my TCP and UDP port range for the container group definitions are set to the same port.

However, I am only able to connect to the protocol that is at the bottom of the setting list

I can only use TCP to connect when the configuration is in this setting

Enter image description here

I can only use UDP to connect when the configuration is in this setting

Enter image description here

Does anyone have any idea what's going on? Is it not possible to have the same port on TCP and UDP for managed containers?

Thanks!

asked a month ago45 views
1 Answer
0

It seems like you're encountering an issue with AWS GameLift Managed Containers where you cannot use the same port for both TCP and UDP protocols simultaneously. This might be due to how the port configuration is being handled within the GameLift service.

Here are a few steps and considerations to help troubleshoot and potentially resolve the issue:

  1. Check GameLift Documentation: Verify if there are any specific limitations or guidelines mentioned in the AWS GameLift documentation regarding the use of the same port for both TCP and UDP protocols.

  2. Separate Ports for TCP and UDP: If using the same port for both protocols is not supported, consider using separate ports for TCP and UDP. This can help avoid conflicts and ensure that both protocols can be used simultaneously.

  3. Network Configuration: Ensure that your network configuration (both in GameLift and your game server) supports the use of both TCP and UDP protocols. This includes security group settings, firewall rules, and any other network-related configurations.

  4. Game Server Code: Verify that your game server code is correctly handling both TCP and UDP connections. Ensure that the server is listening on the correct ports and protocols as configured in GameLift.

  5. Contact AWS Support: If the issue persists and you cannot find a resolution in the documentation, consider reaching out to AWS Support for further assistance. They can provide more detailed insights and help troubleshoot the issue.

Example Configuration with Separate Ports

If you decide to use separate ports for TCP and UDP, here is an example configuration:

  • TCP Port: 12345
  • UDP Port: 12346

Update your GameLift fleet configuration and game server code to use these ports accordingly.

GameLift Fleet Configuration

Ensure your fleet configuration includes both TCP and UDP port ranges:

{
  "PortSettings": [
    {
      "Name": "TCPPort",
      "Protocol": "TCP",
      "PortRange": {
        "FromPort": 12345,
        "ToPort": 12345
      }
    },
    {
      "Name": "UDPPort",
      "Protocol": "UDP",
      "PortRange": {
        "FromPort": 12346,
        "ToPort": 12346
      }
    }
  ]
}

Game Server Code

Ensure your game server is listening on the correct ports for both TCP and UDP:

import socket

# TCP Server
tcp_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_server.bind(('0.0.0.0', 12345))
tcp_server.listen(5)
print("TCP server listening on port 12345")

# UDP Server
udp_server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_server.bind(('0.0.0.0', 12346))
print("UDP server listening on port 12346")

# Handle connections (example)
while True:
    # Accept TCP connections
    tcp_conn, tcp_addr = tcp_server.accept()
    print(f"TCP connection from {tcp_addr}")

    # Receive UDP messages
    udp_data, udp_addr = udp_server.recvfrom(1024)
    print(f"UDP message from {udp_addr}: {udp_data}")

By using separate ports for TCP and UDP, you can avoid conflicts and ensure that both protocols are supported simultaneously. If you still need to use the same port for both protocols, contacting AWS Support would be the best course of action to get a definitive answer and potential workaround.

profile picture
EXPERT
answered 17 days ago

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.

Guidelines for Answering Questions