因此,我很欣赏这将是一个非常晦涩的问题,但我无法在任何地方找到答案。我正在使用.Net Core 2.2和React(默认的Visual Studio项目),并在Linux docker容器中构建该项目并使用nginx作为网关,但是我在开发中遇到了热重载无法正常工作的问题,据我所知这是因为它必须使用的WebSocket无法正确路由。我得到的堆栈跟踪如下。我还在构建许多其他项目,因此错误可能不全是Web项目,大多数情况下,我认为SQL异常与Web项目无关。
[40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.SpaServices[0]
> PROJECT.Web@0.1.0 start /app/ClientApp
> rimraf ./build && react-scripts start
Starting the development server...
Microsoft.AspNetCore.SpaServices:Information: > PROJECT.Web@0.1.0 start /app/ClientApp
> rimraf ./build && react-scripts start
Starting the development server...
Exception thrown: 'System.Data.SqlClient.SqlException' in Microsoft.EntityFrameworkCore.SqlServer.dll
The thread 66 has exited with code 0 (0x0).
The thread 0x42 has exited with code 0 (0x0).
The thread 65 has exited with code 0 (0x0).
The thread 0x41 has exited with code 0 (0x0).
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in Microsoft.EntityFrameworkCore.SqlServer.dll
The thread 76 has exited with code 0 (0x0).
The thread 0x4c has exited with code 0 (0x0).
[40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.SpaServices[0]
Files successfully emitted, waiting for typecheck results...
Microsoft.AspNetCore.SpaServices:Information:
Files successfully emitted, waiting for typecheck results...
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
The thread 99 has exited with code 0 (0x0).
The thread 0x63 has exited with code 0 (0x0).
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
The thread 107 has exited with code 0 (0x0).
The thread 0x6b has exited with code 0 (0x0).
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
The thread 60 has exited with code 0 (0x0).
The thread 0x3c has exited with code 0 (0x0).
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
[40m[32minfo[39m[22m[49m: Microsoft.AspNetCore.SpaServices[0]
Compiled successfully!
Microsoft.AspNetCore.SpaServices:Information: Compiled successfully!
Exception thrown: 'System.Net.Internals.SocketExceptionFactory.ExtendedSocketException' in System.Net.NameResolution.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.SqlClient.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in Microsoft.EntityFrameworkCore.SqlServer.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in Polly.dll
虽然没有完整的堆栈跟踪信息,但您有主要的想法...我相信这与在后台通过sock-js发出的websocket请求有关
最初是错误的,直到我将以下内容添加到我的nginx conf文件中
location /sockjs-node {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_buffering off;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://portal/sockjs-node;
proxy_redirect off;
proxy_read_timeout 90;
}
哪个提供了在devtools映像中看到的响应,但是热重载不起作用。我找到了一种解决方法,可以在配置中单独路由ws请求和以下内容
location /sockjs-node {
try_files /nonexistent @$http_upgrade;
}
location @websocket {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_buffering off;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://portal/sockjs-node;
proxy_redirect off;
proxy_read_timeout 90;
}
location @ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://portal/sockjs-node;
proxy_redirect off;
proxy_read_timeout 90;
}
但是,通过此操作我得到了错误[emerg] 1#1: "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in /etc/nginx/nginx.conf:151
-我发现的唯一解决方案是从没有的/
网址中删除结尾的proxy_pass
。 / p>
简而言之,我完全陷入了困境,是否有人知道这个问题可能是什么,或者可以指出正确的方向?让我知道您是否需要更多信息。
编辑:最值得注意的是当我在浏览器中实际访问网页时不断弹出的这些异常
Exception thrown: 'System.Net.Sockets.SocketException' in Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll
Exception thrown: 'System.IO.DirectoryNotFoundException' in System.Private.CoreLib.dll