来自 IConnectionAdapter 的 OnConnectionAsync 方法的未捕获异常
Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter
我使用 asp.net 核心 2.2 并在我们的互联网服务器上启动应用程序 作为控制台应用程序 (kestrel)。
已附加 有效 public 证书 (.pfx,请参阅下面 appsettings.json 中的配置)。
问题:
- 如果我通过互联网在内部和外部测试应用程序,我无法理解任何问题(一切都按预期工作)。
- 我可以正常启动应用程序。
- 但偶尔(不是理解,不是挑衅),我在控制台中有错误消息(崩溃异常)(见下文)。
- 当崩溃发生时,它们通常会发生多次(大多数 > 10 次)- 不幸的是,我不能说是在什么时间范围内(因为没有时间戳被写入控制台)。
- 此外,我经常(奇怪地)在错误消息后的控制台上有很多空行。
Appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
,
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5001"
},
"HttpsInlineCertFile": {
"Url": "https://192.168.3.3",
"Protocols": "Http1AndHttp2",
"Certificate": {
"Path": "./certificate_2021.pfx",
"Password": "Passwort",
"AllowInvalid": "true"
}
}
}
}
}
注意:证书不是导入到服务器的证书库中(我认为不需要)。
我已经在互联网上搜索了几天,但没有找到任何提示,这让我朝着正确的方向前进。
感谢您的帮助。
异常:
fail: Microsoft.AspNetCore.Server.Kestrel[0]
Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter.
System.Net.InternalException: Exception of type 'System.Net.InternalException' was thrown.
at System.Net.SecurityStatusAdapterPal.GetSecurityStatusPalFromInterop(SECURITY_STATUS win32SecurityStatus, Boolean attachException)
at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output)
at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslState.ThrowIfExceptional()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__51_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.HttpConnection.ApplyConnectionAdaptersAsync()
我认为(希望如此),我已经“隐含地”解决了这个问题(最终确定要早):
- 由于其他原因,我几天前在 startup.cs
中添加了一个从 http 到 https 的重定向
- 从那以后,我似乎再也没有在控制台中崩溃过
我无法控制,什么样的 users/tools 通过互联网访问应用程序。
所以...从我的角度来看(不要通过 https 上的标准浏览器使用“合法”应用程序来理解/挑起)这可能是一个合理的原因。
在 startup.cs
中添加了代码
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
app.UseRewriter(new RewriteOptions().AddRedirectToHttps(StatusCodes.Status301MovedPermanently, 443));
}
我使用 asp.net 核心 2.2 并在我们的互联网服务器上启动应用程序 作为控制台应用程序 (kestrel)。
已附加 有效 public 证书 (.pfx,请参阅下面 appsettings.json 中的配置)。
问题:
- 如果我通过互联网在内部和外部测试应用程序,我无法理解任何问题(一切都按预期工作)。
- 我可以正常启动应用程序。
- 但偶尔(不是理解,不是挑衅),我在控制台中有错误消息(崩溃异常)(见下文)。
- 当崩溃发生时,它们通常会发生多次(大多数 > 10 次)- 不幸的是,我不能说是在什么时间范围内(因为没有时间戳被写入控制台)。
- 此外,我经常(奇怪地)在错误消息后的控制台上有很多空行。
Appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
,
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5001"
},
"HttpsInlineCertFile": {
"Url": "https://192.168.3.3",
"Protocols": "Http1AndHttp2",
"Certificate": {
"Path": "./certificate_2021.pfx",
"Password": "Passwort",
"AllowInvalid": "true"
}
}
}
}
}
注意:证书不是导入到服务器的证书库中(我认为不需要)。
我已经在互联网上搜索了几天,但没有找到任何提示,这让我朝着正确的方向前进。
感谢您的帮助。
异常:
fail: Microsoft.AspNetCore.Server.Kestrel[0]
Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter.
System.Net.InternalException: Exception of type 'System.Net.InternalException' was thrown.
at System.Net.SecurityStatusAdapterPal.GetSecurityStatusPalFromInterop(SECURITY_STATUS win32SecurityStatus, Boolean attachException)
at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output)
at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslState.ThrowIfExceptional()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__51_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.HttpConnection.ApplyConnectionAdaptersAsync()
我认为(希望如此),我已经“隐含地”解决了这个问题(最终确定要早):
- 由于其他原因,我几天前在 startup.cs 中添加了一个从 http 到 https 的重定向
- 从那以后,我似乎再也没有在控制台中崩溃过
我无法控制,什么样的 users/tools 通过互联网访问应用程序。
所以...从我的角度来看(不要通过 https 上的标准浏览器使用“合法”应用程序来理解/挑起)这可能是一个合理的原因。
在 startup.cs
中添加了代码 if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
app.UseRewriter(new RewriteOptions().AddRedirectToHttps(StatusCodes.Status301MovedPermanently, 443));
}