[英]vscode debugging returns “An unhandled exception occurred while processing the request”
I am trying to debug a dotnet react app. 我正在尝试调试dotnet react应用。 "dotnet run" works fine.
“ dotnet运行”可以正常工作。 However, debugging my dotnet react app on vscode returns "conntection refused at
Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task<Uri> baseUriTask, CancellationToken applicationStoppingToken, bool proxy404s)
" 但是,在vscode上调试我的dotnet react应用程序将返回“
Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task<Uri> baseUriTask, CancellationToken applicationStoppingToken, bool proxy404s)
”
The application I am making has a dotnet core backend and react as the front end which is made possible by microsoft spa services. 我正在制作的应用程序具有dotnet核心后端,并作为前端响应,这是Microsoft spa服务使之成为可能的。 I have tried many fixes that have worked for others such as upgrading my dotnet-sdk but I still get the issue.
我已经尝试了许多对其他人有用的修复程序,例如升级dotnet-sdk,但仍然遇到问题。
Here are my launch.json configurations 这是我的launch.json配置
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/debate.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]```
This is my build task
```"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/debate.csproj"
],
"problemMatcher": "$tsc"
}
In my startup.cs i cannot debug past this line spa.UseReactDevelopmentServer(npmScript: "start");
在我的startup.cs中,我无法调试通过此行
spa.UseReactDevelopmentServer(npmScript: "start");
Here is the error message a recieve 这是收到的错误消息
fail: Microsoft.AspNetCore.SpaServices[0]
events.js:183
Microsoft.AspNetCore.SpaServices:Error: events.js:183
fail: Microsoft.AspNetCore.SpaServices[0]
throw er; // Unhandled 'error' event
And on the browser, I get 在浏览器上
System.Net.Http.ConnectHelper.ConnectAsync(string host, int port, CancellationToken cancellationToken)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask<ValueTuple<HttpConnection, HttpResponseMessage>> creationTask)
System.Threading.Tasks.ValueTask<TResult>.get_Result()
System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, bool doRequestAuth, CancellationToken cancellationToken)
System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task<HttpResponseMessage> sendTask, HttpRequestMessage request, CancellationTokenSource cts, bool disposeCts)
Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task<Uri> baseUriTask, CancellationToken applicationStoppingToken, bool proxy404s)```
I was able to reproduce the error 'dotnet run' instead of 'sudo donet run'.
I noticed that the node proccess doesnt end even after I stop debugging. 我注意到即使停止调试,节点处理也不会结束。 So ending it manually using killall node before I start another debugging session stopped producing the error.
因此,在启动另一个调试会话之前,使用killall节点手动结束它会停止产生该错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.