Skip to main content
All CollectionsTroubleshooting
Relay/P2P Troubleshooting
Relay/P2P Troubleshooting

Troubleshoot relay and P2P connections in Level, covering STUN/TURN servers, testing tools, network requirements, and common steps.

Updated over a week ago

When the Level agent cannot establish a peer-to-peer (P2P) connection for remote control, it falls back to using relay servers. To help troubleshoot and resolve these issues, this guide provides tips on testing P2P, STUN, and TURN connections and outlines the tools and endpoints used by Level.

Understanding P2P and Relay Connections

  • P2P (Peer-to-Peer): This is the preferred connection method as it typically provides lower latency and better performance. P2P connections are established using STUN (Session Traversal Utilities for NAT) servers to help discover the public IP address and establish a direct connection.

  • Relay Connections: If P2P fails, the system will rely on TURN (Traversal Using Relays around NAT) servers to relay traffic through a third-party server. This is necessary when direct P2P is not possible due to NAT/firewall configurations.

Connection Testing Tools

To assist in testing and verifying connections, you can use the following tools:

  • Trickle ICE Test: This tool can be used to verify ICE candidates and test STUN and TURN server configurations.

  • Twilio Network Test: This tool checks the connectivity of Twilio’s global STUN and TURN servers, which are used by Level in case P2P connections cannot be made.

Testing P2P, STUN, and TURN

To determine if a P2P connection can be established, you can test the following:

  1. STUN Server Test: Used to discover public IPs and port mappings. Level uses global.stun.twilio.com.

  2. TURN Server Test: Used when a direct P2P connection fails, routing traffic through global.turn.twilio.com.

We recommend running network tests with tools like the Twilio Network Test to ensure there are no network or firewall rules blocking access to these services.

Common Troubleshooting Steps

  • Check Network Access: Ensure outbound TCP connections over port 443 are allowed to the following URLs:

    • agents.level.io (agent communication)

    • online.level.io (connectivity status checks)

    • builds.level.io (agent updates)

    • downloads.level.io (initial agent install)

    • global.turn.twilio.com (TURN server)

    • global.stun.twilio.com (STUN server)

  • Verify Firewall/NAT Configuration: Ensure the network allows UDP traffic for STUN and TURN or TCP over port 443 if needed. Confirm that any firewall rules or NAT settings do not block the Twilio STUN/TURN servers.

Investigating P2P vs Relay Connections

  • You can investigate whether the connection is using P2P or relay by checking logs from the agent or by performing a packet capture on the network. If the connection is relayed, the traffic will typically flow through Twilio’s TURN server.

Additional Testing for Connectivity Issues

  • Use a tool like Wireshark to capture traffic and verify that UDP traffic is being sent and received from the STUN/TURN servers.

  • You can also manually run tests using Trickle ICE to see if valid ICE candidates are returned for P2P.

Future Testing Tool

We are considering creating a dedicated troubleshooting page that will allow users to directly test STUN, TURN, and P2P connections to the Twilio and Google endpoints used by Level. Stay tuned for updates.

Did this answer your question?