egametang/ET · error · Exception

get router fail: {netComponent.Root().Id} {address}

Error message

get router fail: {netComponent.Root().Id} {address}

What it means

Thrown by RouterHelper.CreateRouterSession when the router SYN handshake returns recvLocalConn == 0. Looking at the Connect method, this happens when the retry loop exhausts 20 attempts (sending RouterSYN every 300ms) or when the TimerComponent is destroyed mid-handshake. It means the router server never acknowledged the connection request.

Source

Thrown at Packages/cn.etetet.login/Scripts/Hotfix/Client/NetClient/Router/RouterHelper.cs:18

using System;
using System.Net;

namespace ET.Client
{
    public static partial class RouterHelper
    {
        // 注册router
        public static async ETTask<Session> CreateRouterSession(this NetComponent netComponent, IPEndPoint address, string account, string password)
        {
            EntityRef<NetComponent> netComponentRef = netComponent;
            uint localConn = (uint)(account.GetLongHashCode() ^ password.GetLongHashCode() ^ RandomGenerator.RandUInt32());
            (uint recvLocalConn, IPEndPoint routerAddress) = await GetRouterAddress(netComponent, address, localConn, 0);
            
            netComponent = netComponentRef;
            if (recvLocalConn == 0)
            {
                throw new Exception($"get router fail: {netComponent.Root().Id} {address}");
            }
            
            Log.Info($"get router: {recvLocalConn} {routerAddress}");

            Session routerSession = netComponent.Create(routerAddress, address, recvLocalConn);
            routerSession.AddComponent<PingComponent>();
            routerSession.AddComponent<RouterCheckComponent>();
            
            return routerSession;
        }
        
        public static async ETTask<(uint, IPEndPoint)> GetRouterAddress(this NetComponent netComponent, IPEndPoint address, uint localConn, uint remoteConn)
        {
            EntityRef<NetComponent> netComponentRef = netComponent;
            Log.Info($"start get router address: {netComponent.Root().Id} {address} {localConn} {remoteConn}");
            //return (RandomHelper.RandUInt32(), address);
            RouterAddressComponent routerAddressComponent = netComponent.Root().GetComponent<RouterAddressComponent>();
            IPEndPoint routerInfo = routerAddressComponent.GetAddress();

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Verify the router server is running and reachable at the configured IP/port — check UDP connectivity and firewall rules.
  2. Check the router address configuration (RouterAddressComponent.GetAddress returns the correct endpoint).
  3. If network conditions are poor, consider increasing the retry count or interval in the Connect method (currently 20 retries at 300ms).
  4. Ensure the NetComponent and its TimerComponent are not disposed during the handshake.

Example fix

// before: 20 retries at 300ms
int count = 20;
// after: increase retries for unstable networks
int count = 40;
Defensive patterns

Strategy: retry

Validate before calling

// Validate router reachability before full handshake
IPEndPoint routerAddr = netComponent.Root().GetComponent<RouterAddressComponent>().GetAddress();
if (routerAddr == null)
{
    Log.Error("Router address component returned null endpoint");
    return null;
}

Try / catch

try { Session s = await netComponent.CreateRouterSession(address, account, password); } catch (Exception e) { Log.Error($"Router connection failed: {e.Message}"); /* show user retry prompt */ }

Prevention

When it happens

Trigger: CreateRouterSession calls GetRouterAddress -> Connect, which sends up to 20 SYN packets to the router address. If the router never responds with an ACK (routerConnector.Flag stays 0), or the TimerComponent becomes null, Connect returns 0 and CreateRouterSession throws.

Common situations: Router server is down or unreachable at the configured address. Firewall blocks UDP traffic (KCP-based router). Router address is misconfigured (wrong IP/port). Network latency exceeds the 20-retry * 300ms window (~6 seconds). RouterConnector component was disposed before the handshake completed.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/78282af84acd5ca6. Report an issue: GitHub.