{"record":{"id":"d4cc47be870d25c0","repo":"netchx/netch","slug":"name","errorCode":null,"errorMessage":"{Name} 控制器启动失败","messagePattern":"(.+?) 控制器启动失败","errorType":"exception","errorClass":"MessageException","httpStatus":null,"severity":"error","filePath":"Netch/Controllers/Guard.cs","lineNumber":96,"sourceCode":"            {\n                // Skip, No started keyword\n                State = State.Started;\n                return;\n            }\n\n            // wait ReadOutput change State\n            for (var i = 0; i < 1000; i++)\n            {\n                await Task.Delay(50);\n                switch (State)\n                {\n                    case State.Started:\n                        OnStarted();\n                        return;\n                    case State.Stopped:\n                        await StopGuardAsync();\n                        OnStartFailed();\n                        throw new MessageException($\"{Name} 控制器启动失败\");\n                }\n            }\n\n            await StopGuardAsync();\n            throw new MessageException($\"{Name} 控制器启动超时\");\n        }\n    }\n\n    private async Task ReadOutputAsync(TextReader reader)\n    {\n        string? line;\n        while ((line = await reader.ReadLineAsync()) != null)\n        {\n            await _logStreamWriter!.WriteLineAsync(line);\n            OnReadNewLine(line);\n\n            if (State == State.Starting)\n            {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/netchx/netch/blob/9d99eb1c5a2acbf2a34f2600f94242601019a300/Netch/Controllers/Guard.cs#L78-L114","documentation":"Thrown by Guard.StartGuardAsync when the launched child process transitioned to State.Stopped during startup — meaning ReadOutputAsync saw a line matching one of the controller's FailedKeywords, or the process exited before printing any StartedKeyword. The controller had RedirectOutput on and a non-empty StartedKeywords list, so it actively watched stdout/stderr. OnStartFailed runs first (default opens the log file), then this exception propagates.","triggerScenarios":"Child process (pcap2socks, v2ray, etc.) prints a configured FailedKeyword and exits; child crashes immediately due to bad arguments assembled by the controller; child cannot bind its listen port; child missing its own runtime dependency so it errors out and dies.","commonSituations":"Server config (host/port/password) passed as args is rejected by the child; port conflict for the child's own listener; version mismatch between Netch's arg format and the bundled binary; certificate/permission errors in the child logged as a failure keyword.","solutions":["Read the log file that OnStartFailed just opened (logging\\<Name>.log) for the child's actual error line.","Correct the server/mode configuration that was serialized into the child's arguments.","Free the port the child needs or stop the conflicting process.","If the child needs a runtime (e.g. Npcap for pcap2socks), install it.","Reinstall Netch to get a binary version whose CLI matches the controller's arg assembly."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await guard.StartGuardAsync(args); }\ncatch (MessageException ex) when (ex.Message.EndsWith(\"控制器启动失败\"))\n{\n    // OnStartFailed already opened logging\\<Name>.log; surface its last line to the user.\n    var lastLine = File.ReadLines(guard.LogPath).LastOrDefault();\n    Global.MainForm.StatusText($\"{guard.Name} failed: {lastLine}\");\n}","preventionTips":["Always read the child's log file on failure rather than guessing from the generic message.","Keep StartedKeywords/FailedKeywords in sync with the bundled binary version.","Free the child's required ports before launching to avoid early exit.","Install the child's runtime dependencies (Npcap, etc.) before first launch."],"tags":["process","startup","native-interop","logging"],"backgroundTag":null,"analyzedSha":"9d99eb1c5a2acbf2a34f2600f94242601019a300","analyzedAt":"2026-08-13T14:12:19.105Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}