Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF PostgreSQL throws “The message received was unexpected or badly formatted” on Windows 8 #160

Open
tomasr78 opened this issue Jun 19, 2020 · 0 comments

Comments

@tomasr78
Copy link

I just can't find a reason why EF 6 PostgreSQL throws an exception on Windows 8 but works perfectly on Windows 10. The PostgreSQL hosted on IBM PostgreSQL Cloud and accessed using a secured connection(SSL).

The connection string

  <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>

The error message.

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.

Looking from full-stack trace I find that the exception related to SSL and last executed method is System.Net.Security.SslState.StartSendAuthResetSignal

The full stack trace

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant