Intermittent SSPI error - unable to connect postgres

I randomly get this error - then when I retry it works fine. Causing scheduled tasks to fail. Is there a log file that can provide more details about why the connection is failing. Sometimes on read, other times when writing to postgres - doesn't seem source data related.

I found the debug file: Hope this helps.

[0] Exception message: A call to SSPI failed, see inner exception.
[0] Exception type: AuthenticationException
[0] Exception source: System
[0] Exception stack trace: at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte buffer, Int32 count, 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.ForceAuthentication(Boolean receiveFirst, Byte buffer, AsyncProtocolRequest asyncRequest, Boolean renegotiation)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at Npgsql.NpgsqlConnector.d__150.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlConnector.d__146.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Npgsql.ConnectorPool.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<g__OpenLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlConnection.Open()
at Morph.DataDrivers.Database.DatabaseExportDriver.#=zBxnkdNq3vCNTDdvaDcRojTA=.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at  ..Invoke(Unit )
at Ply.TplPrimitives.ContinuationStateMachine1.System-Runtime-CompilerServices-IAsyncStateMachine-MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at  .​.Invoke(Unit )
at Ply.TplPrimitives.ContinuationStateMachine1.System-Runtime-CompilerServices-IAsyncStateMachine-MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at  . .Invoke(Unit ) at Ply.TplPrimitives.tryFinally[u](FSharpFunc2 continuation, FSharpFunc2 finallyBody) at Ply.TplPrimitives.tryWith[u](FSharpFunc2 continuation, FSharpFunc`2 catch)
==inner exception [1]==

[1] Exception message: The message received was unexpected or badly formatted
[1] Exception type: Win32Exception
[1] Exception source is empty
[1] Exception stack trace is empty
[1] Inner exception is empty
20241103 06:39:46 [DBG] [UI] Run module 'Main'
20241103 06:39:46 [ERR] [UI] Run completed with 1 errors
20241103 06:39:46 [ERR] [UI] Error: A call to SSPI failed, see inner exception.
The message received was unexpected or badly formatted
Source: action "Export to database", table "Imported table 1"

What type of connector in EasyMorph do you use - ODBC or native?

@CTN, when did that error start to appear? What is your EasyMorph Server version, PostgreSQL version, and Windows version on the computer where EasyMorph Server is installed? Did you update any of those around the time that error started to appear?

just building the project and it seems to be random. even just pressing "test connector" it randomly fails. On the first screenshot below you can see how it failed on the first iteration (common) and then was fine with the rest. Basically reading a list from same postgres database and then iterating through each row to retrieve data based on parameters shown.

PostgreSQL 16.4
Easymorph 5.8.1

And what is your Windows version?

Cloud PC Windows 365

As far as I understand, Windows 365 service can run either Windows 10 or Windows 11. So which one do you have?

Windows 11. The issue is that the connection intermittently fails for some reason so would be helpful if there was a retry say after 1 second vs erroring out right away. Is there a way to retry a connection if it fails?

Connection errors are usually not intermittent, so there is no reason for EasyMorph to always repeat them. However, you can create a workflow that will repeat the whole operation in case of an error using the "Repeat" action. Let me know if that approach is feasible for you, and if it is, I'll create an example project for you.

As for the error itself, it seems like a bug in your PostgreSQL version. That bug is already fixed, and the fixed version is planned for release on November 14th.

In the meantime, you can try a couple of things to fix that error:

  • Update EasyMorph to the latest version (5.8.2). The latest version supports TLS 1.3, so that might fix the error
  • Install the PostgreSQL ODBC driver and use the ODBC connector in EasyMorph instead of the native one. Since the error is in the database itself, it might result in the same or a similar error, but it's worth a try
  • Disable ssl_ca_file in the postgresql.conf file.

Hi @CTN,

Just letting you know that PostgreSQL 16.5, with a fix for the bug in question, was released a few days ago.

1 Like