{"record":{"id":"3a8690b18191266a","repo":"stride3d/stride","slug":"connection-router-did-not-connect-back-to-our-listen-socket","errorCode":null,"errorMessage":"Connection router did not connect back to our listen socket","messagePattern":"Connection router did not connect back to our listen socket","errorType":"exception","errorClass":"SimpleSocketException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Engine/Network/RouterClient.cs","lineNumber":117,"sourceCode":"                            socketContext.StartClient(serverAddress, DefaultPort);\n                        }\n                        catch (Exception) // Ideally we should filter SocketException, but not available on some platforms (maybe it should be wrapped in a type available on all paltforms?)\n                        {\n                            clientException = true;\n                        }\n                        if (clientException)\n                        {\n                            socketContext.StartServer(DefaultListenPort, true, 10);\n                        }\n                        break;\n                    default:\n                        throw new ArgumentOutOfRangeException();\n                }\n\n                // Connection should happen within 10 seconds, otherwise consider there is no connection router trying to connect back to us\n                if (await Task.WhenAny(socketContextTCS.Task, Task.Delay(TimeSpan.FromSeconds(10))).ConfigureAwait(false) != socketContextTCS.Task)\n                {\n                    throw new SimpleSocketException(\"Connection router did not connect back to our listen socket\");\n                }\n\n                return await socketContextTCS.Task;\n            }\n            catch (Exception e)\n            {\n                Log.Error($\"Could not connect to connection router using mode {ConnectionMode}\", e);\n                throw;\n            }\n        }\n\n        private static void StartControlConnection()\n        {\n            // Start control connection\n            throw new NotImplementedException();\n        }\n\n        /// <summary>","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Engine/Network/RouterClient.cs#L99-L135","documentation":"InitiateConnectionToRouter throws SimpleSocketException when, after asking the router to connect back, no incoming socket arrives on the client's listening socket within 10 seconds (Task.Delay wins over the TaskCompletionSource). It means the router never dialed back.","triggerScenarios":"Requesting a connection to a router but the router (or its peer) fails to connect back to the client's listen socket within the 10-second window.","commonSituations":"Firewall/NAT blocking the router's callback connection to the client port; router overloaded or dead; client listen socket bound to an address unreachable by the router.","solutions":["Verify the router can reach the client's listen socket (open firewall/NAT ports).","Check the client is listening on an address the router can connect to (not localhost in remote setups).","Confirm the router service is alive and processing requests.","Retry the initiate call; investigate logs if it times out repeatedly."],"exampleFix":"// before\n// listening on loopback, router on another machine\nvar ctx = await routerClient.InitiateConnectionToRouter(\"tcp://router:10000\");\n// after\nvar ctx = await routerClient.InitiateConnectionToRouter(\"tcp://router:10000\", listenOnReachableExternalAddress);","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { ctx = await router.InitiateConnectionToRouter(url); }\ncatch (SimpleSocketException) { /* callback blocked: check firewall/NAT, retry */ }","preventionTips":["Open inbound firewall/NAT rules for the client's listen socket.","Listen on an externally reachable address, not loopback, for remote routers.","Monitor router health and retry connection initiation on timeout."],"tags":["network","socket","timeout","router","firewall"],"backgroundTag":"request-timeout","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}