EF PostgreSQL выдает "Полученное сообщение было неожиданным или плохо отформатировано" на Windows 8. - PullRequest
0 голосов
/ 19 июня 2020

Я просто не могу найти причину, по которой EF PostgreSQL выдает исключение на Windows 8, но отлично работает на Windows 10. PostgreSQL размещен в IBM PostgreSQL Cloud и доступен с помощью защищенного соединения (SSL).

Строка подключения

  <connectionStrings>
    <add name="DatabaseContext"
      connectionString="host=xxx.databases.appdomain.cloud;port=30308;database=ca;user id=admin;password=xxx;sslmode=Require;Trust Server Certificate=true;Timeout=100"
      providerName="Npgsql"/>
  </connectionStrings>

Сообщение об ошибке.

An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor... -> A call to SSPI failed, see inner exception. -> The message received was unexpected or badly formatted.

Просматривая трассировку полного стека, я обнаружил, что исключение, связанное с SSL и последним выполненным методом: System.Net.Security.SslState.StartSendAuthResetSignal

Полная трассировка стека

ClassNameSystem.Data.Entity.Core.ProviderIncompatibleExceptionMessageAn error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.StackTraceString   at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
   at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
   at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
   at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.Initialize()
   at CARA.Server.Startup.Configuration(IAppBuilder appBuilder) in d:\a\1\s\CARA.Server\Startup.cs:line 29RemoteStackIndex0ExceptionMethod8
GetProviderManifestTokenChecked
EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data.Entity.Utilities.DbProviderServicesExtensions
System.String GetProviderManifestTokenChecked(System.Data.Entity.Core.Common.DbProviderServices, System.Data.Common.DbConnection)HResult-2146233087SourceEntityFrameworkDataInnerException
ClassNameSystem.Data.Entity.Core.ProviderIncompatibleExceptionMessageThe provider did not return a ProviderManifestToken string.DatanullInnerException{
  "ClassName": "System.Security.Authentication.AuthenticationException",
  "Message": "A call to SSPI failed, see inner exception.",
  "Data": null,
  "InnerException": {
    "NativeErrorCode": -2146893018,
    "ClassName": "System.ComponentModel.Win32Exception",
    "Message": "The message received was unexpected or badly formatted",
    "Data": null,
    "InnerException": null,
    "HelpURL": null,
    "StackTraceString": null,
    "RemoteStackTraceString": null,
    "RemoteStackIndex": 0,
    "ExceptionMethod": null,
    "HResult": -2147467259,
    "Source": null,
    "WatsonBuckets": null
  },
  "HelpURL": null,
  "StackTraceString": "   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)\r\n   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)\r\n   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)\r\n   at Npgsql.NpgsqlConnector.<RawOpen>d__152.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Npgsql.NpgsqlConnector.<Open>d__148.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<<Open>g__OpenLong|0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Npgsql.NpgsqlConnection.Open()\r\n   at Npgsql.NpgsqlServices.UsingPostgresDbConnection(NpgsqlConnection connection, Action`1 action)\r\n   at Npgsql.NpgsqlServices.GetDbProviderManifestToken(DbConnection connection)\r\n   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)",
  "RemoteStackTraceString": null,
  "RemoteStackIndex": 0,
  "ExceptionMethod": "8\nStartSendAuthResetSignal\nSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Net.Security.SslState\nVoid StartSendAuthResetSignal(System.Net.Security.ProtocolToken, System.Net.AsyncProtocolRequest, System.Exception)",
  "HResult": -2146233087,
  "Source": "System",
  "WatsonBuckets": null
}HelpURLnullStackTraceString   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
   at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)RemoteStackTraceStringnullRemoteStackIndex0ExceptionMethod8
GetProviderManifestToken
EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Data.Entity.Core.Common.DbProviderServices
System.String GetProviderManifestToken(System.Data.Common.DbConnection)
...