我正在尝试调试dotnet react应用。 “ dotnet运行”可以正常工作。但是,在vscode上调试我的dotnet react应用程序会返回“在Microsoft.AspNetCore.SpaServices.Extensions.Proxy.SpaProxy.PerformProxyRequest(HttpContext context, HttpClient httpClient, Task<Uri> baseUriTask, CancellationToken applicationStoppingToken, bool proxy404s)
上拒绝连接”
我正在制作的应用程序具有一个dotnet核心后端,并且作为前端响应,这是由Microsoft spa服务实现的。我已经尝试了许多对其他人有用的修复程序,例如升级dotnet-sdk,但仍然遇到问题。
这是我的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"
}
在我的startup.cs中,我无法调试超过此行
spa.UseReactDevelopmentServer(npmScript: "start");
这是收到的错误消息
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
在浏览器上,我得到
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'.
答案 0 :(得分:0)
我注意到即使停止调试,节点处理也不会结束。因此,在我启动另一个调试会话之前,使用 killall节点手动结束它会停止产生该错误。