简体   繁体   English

运行 Postman 的 Newman 命令时命令挂在 C# 中

[英]Command hanging in C# when running Postman's Newman command

I'm trying to use cmd CLI to excute a newman collection run.我正在尝试使用 cmd CLI 来执行 newman 集合运行。 However when the process is running it's getting stuck and never finishes processing.但是,当进程正在运行时,它会卡住并且永远不会完成处理。

Any suggestions on how to deal with that?有关如何处理的任何建议?

string cmdCommand="newman run demo.postman_collection.json --env-var HTTP_PROXY --insecure";
int TotalTimeout= 150000;
CliProcess = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new 
System.Diagnostics.ProcessStartInfo();
if (_inputDir != null)
{
    startInfo.WorkingDirectory = _inputDir;
}
//startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = false;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C "+cmdCommand;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardInput = true;
bool processExited;            
startInfo.RedirectStandardOutput = false;
CliProcess.StartInfo = startInfo;            
CliProcess.Start();
CliProcess.StandardInput.WriteLine("exit");
//CliProcess.BeginOutputReadLine();
//CliProcess.BeginErrorReadLine();
//CliProcess.Close();
processExited = CliProcess.WaitForExit(TotalTimeout);
//                //&& outputWaitHandle.WaitOne(TotalTimeout) && errorWaitHandle.WaitOne(TotalTimeout);
//CliProcess.CancelOutputRead();
//CliProcess.CancelErrorRead();
//ExitCode = GetProcessExitCode();
//CliProcess.Kill();
//}

//Wait additional minute for the process to exit
if (!processExited)
{
    KillNewman();
    TraceLogger.Instance.LogMessage(TraceLevel.Warning, MsgSrc, "[SendCmdCommand(string cmdCommand)] Newman process was killed due to timeout");
}

This is the most I can get out of it:这是我能从中得到的最多的东西:

命令结果

It gets stuck here^ and never continues.它卡在这里^ 并且永远不会继续。

问题是由于代理配置错误,因此发送请求试图到达无响应的代理服务器......所以总而言之,代码本身没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM