序列号MSSqlServer HTTPs连接错误



使用.net core 3.1和serilog sql server sink,数据不会写入数据库。在我的控制台上启用serilog selfog出现以下错误:

无法对HTTPS连接进行身份验证。System.IO.IOException:身份验证失败,因为远程参与方已关闭传输流。

在手动创建数据库并启动应用程序之后;错误日志";表是在数据库中创建的(使用serilog配置(,但当涉及到插入日志时,就会发生这种情况。

更新

无论我使用什么水槽,我都会面临同样的错误!

[17:14:10 INF] Hello, world!
[17:14:10 DBG] Hosting starting
[17:14:10 DBG] Failed to locate the development https certificate at 'null'.
[17:14:10 DBG] Using development certificate: CN=localhost (Thumbprint: 042981E3AFFFDD00DE844A41D4437C2A52529AEB)
[17:14:10 INF] Now listening on: https://localhost:5001
[17:14:10 INF] Now listening on: http://localhost:5000
[17:14:10 DBG] Loaded hosting startup assembly demo-log
[17:14:10 INF] Application started. Press Ctrl+C to shut down.
[17:14:10 INF] Hosting environment: Development
[17:14:10 INF] Content root path: C:UsersOmidsourcereposdemo-logdemo-log
[17:14:10 DBG] Hosting started
[17:14:11 DBG] Connection id "0HM29NMTJB5T6" received FIN.
[17:14:11 DBG] Connection id "0HM29NMTJB5T7" received FIN.
[17:14:11 DBG] Connection id "0HM29NMTJB5T7" accepted.
[17:14:11 DBG] Connection id "0HM29NMTJB5T6" accepted.
[17:14:11 DBG] Connection id "0HM29NMTJB5T7" started.
[17:14:11 DBG] Connection id "0HM29NMTJB5T6" started.
[17:14:11 DBG] Failed to authenticate HTTPS connection.
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessAuthentication(LazyAsyncResult lazyResult, CancellationToken cancellationToken)
at System.Net.Security.SslStream.BeginAuthenticateAsServer(SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__69_0(SslServerAuthenticationOptions arg1, CancellationToken arg2, AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state)
at System.Net.Security.SslStream.AuthenticateAsServerAsync(SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.InnerOnConnectionAsync(ConnectionContext context)
[17:14:11 DBG] Failed to authenticate HTTPS connection.
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessAuthentication(LazyAsyncResult lazyResult, CancellationToken cancellationToken)
at System.Net.Security.SslStream.BeginAuthenticateAsServer(SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__69_0(SslServerAuthenticationOptions arg1, CancellationToken arg2, AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state)
at System.Net.Security.SslStream.AuthenticateAsServerAsync(SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.InnerOnConnectionAsync(ConnectionContext context)
[17:14:11 DBG] Connection id "0HM29NMTJB5T7" stopped.
[17:14:11 DBG] Connection id "0HM29NMTJB5T6" stopped.
[17:14:11 DBG] Connection id "0HM29NMTJB5T6" sending FIN because: "The Socket transport's send loop completed gracefully."
[17:14:11 DBG] Connection id "0HM29NMTJB5T7" sending FIN because: "The Socket transport's send loop completed gracefully."
[17:14:11 DBG] Connection id "0HM29NMTJB5T8" accepted.
[17:14:11 DBG] Connection id "0HM29NMTJB5T8" started.
[17:14:11 VRB] Connection id "0HM29NMTJB5T8" sending SETTINGS frame for stream ID 0 with length 18 and flags NONE
[17:14:11 VRB] Connection id "0HM29NMTJB5T8" sending WINDOW_UPDATE frame for stream ID 0 with length 4 and flags 0x0
[17:14:11 VRB] Connection id "0HM29NMTJB5T8" received SETTINGS frame for stream ID 0 with length 24 and flags NONE
[17:14:11 VRB] Connection id "0HM29NMTJB5T8" sending SETTINGS frame for stream ID 0 with length 0 and flags ACK
[17:14:11 VRB] Connection id "0HM29NMTJB5T8" received WINDOW_UPDATE frame for stream ID 0 with length 4 and flags 0x0
[17:14:11 VRB] Connection id "0HM29NMTJB5T8" received HEADERS frame for stream ID 1 with length 341 and flags END_STREAM, END_HEADERS, PRIORITY
[17:14:11 VRB] Connection id "0HM29NMTJB5T8" received SETTINGS frame for stream ID 0 with length 0 and flags ACK
[17:14:11 INF] Request starting HTTP/2 GET https://localhost:5001/
[17:14:11 DBG] Wildcard detected, all requests with hosts will be allowed.
[17:14:11 VRB] All hosts are allowed.
[17:14:11 DBG] No candidates found for the request path '/'
[17:14:11 DBG] Request did not match any endpoints
[17:14:11 INF] HTTP GET / responded 404 in 16.8270 ms
[17:14:11 VRB] Connection id "0HM29NMTJB5T8" sending HEADERS frame for stream ID 1 with length 71 and flags END_STREAM, END_HEADERS

使用Serilog登录MSSQL数据库。请使用以下步骤。

  1. 安装以下必需的软件包
    序列号
    Serilog.Sinks.MSSQL
    Serial.Sinks.PeriodicBatching
  2. 创建一个类文件并编写用于登录数据库的函数,并参考以下步骤。
    using Serilog;
    using Serilog.Sinks.MSSqlServer;
    using System.Diagnostics;
    try
    {
    // This doesn't break/I don't get any exceptions.
    Serilog.Debugging.SelfLog.Enable(msg =>
    {
    Debug.Print(msg);
    Debugger.Break();
    });
    var serLog = new LoggerConfiguration()
    .WriteTo.MSSqlServer("yourconnectionstring", 
    "yourtablename")
    .CreateLogger();
    Log.Logger = serLog;
    Log.Information("It works");
    }
    catch (Exception ex)
    {
    Log.Error(ex.ToString());
    }
    finally
    {
    Log.CloseAndFlush();
    }
    

相关内容

  • 没有找到相关文章

最新更新