c# – .NET和MySQL错误 – 对SSPI的调用失败……“收到的消息是意外的或格式错误的”和“提供给函数的缓冲区太小”

前端之家收集整理的这篇文章主要介绍了c# – .NET和MySQL错误 – 对SSPI的调用失败……“收到的消息是意外的或格式错误的”和“提供给函数的缓冲区太小”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我希望这个问题不是太模糊,但我看得很远但却找不到任何有用的错误.

我有一个.NET 4.5.2 Web服务层(使用ServiceStack和Dapper),自从我们部署服务以来,它几乎没有收到这两个错误.

第一个错误

2017-09-29 18:13:26.637 +00:00 [Error] Class: "TokenRepository" | Method: "GetToken"
System.Security.Authentication.AuthenticationException: A call to SSPI Failed,see inner exception. ---> System.ComponentModel.Win32Exception: The message received was unexpected or badly formatted
   --- End of inner exception stack trace ---
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message,AsyncProtocolRequest asyncRequest,Exception exception)
   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.ProcessReceivedBlob(Byte[] buffer,AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst,Byte[] buffer,AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at MysqL.Data.MysqLClient.NativeDriver.StartSSL()
   at MysqL.Data.MysqLClient.NativeDriver.Open()
   at MysqL.Data.MysqLClient.Driver.Open()
   at MysqL.Data.MysqLClient.Driver.Create(MysqLConnectionStringBuilder settings)
   at MysqL.Data.MysqLClient.MysqLPool.CreateNewPooledConnection()
   at MysqL.Data.MysqLClient.MysqLPool.GetPooledConnection()
   at MysqL.Data.MysqLClient.MysqLPool.TryToGetDriver()
   at MysqL.Data.MysqLClient.MysqLPool.GetConnection()
   at MysqL.Data.MysqLClient.MysqLConnection.Open()
   at Dapper.sqlMapper.<QueryImpl>d__125`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Dapper.sqlMapper.Query[T](IDbConnection cnn,String sql,Object param,IDbTransaction transaction,Boolean buffered,Nullable`1 commandTimeout,Nullable`1 commandType)
   at myApp.Services.Data.Impl.TokenRepository.GetToken(String token) in E:\Jenkins\workspace\myApp\src\Services.Data\Impl\TokenRepository.cs:line 191

第二个……

2017-09-19 15:40:51.040 +00:00 [Error] Class: "myApp.Services.Data.Impl.SystemRepository" | Method: "GetAttributes"
System.Security.Authentication.AuthenticationException: A call to SSPI Failed,see inner exception. ---> System.ComponentModel.Win32Exception: The buffers supplied to a function was too small
   --- End of inner exception stack trace ---
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message,Nullable`1 commandType)
   at myApp.Services.Data.Impl.SystemRepository.GetAttributes() in E:\Jenkins\workspace\myApp\src\Services.Data\Impl\SystemRepository.cs:line 38

我的堆栈上有一点背景:

> .NET 4.5.2
> Dapper 1.50.2.0
> ServiceStack 4.5.4
> MysqL 5.6(使用Amazon Aurora)

我们在任何其他环境中都没有收到此错误,我们没有运行Aurora,只是在Amazon RDS上运行MysqL 5.7.17.

正如我所提到的,这些错误是偶发的,并不总是发生在相同的方法/服务上,但它们总是在使用Dapper从服务层到MysqL数据库执行sql命令时发生.

有没有进一步调试这个或者是否有任何与MysqL / Aurora / Dapper相关的已知问题?经过研究,我找不到任何东西.

解决方法

看看这个 https://github.com/mysql-net/MySqlConnector/issues/428

我遇到了类似技术堆栈的同样错误.一个简单的解决方法是在connectionString中添加SslMode = None,它应该可以工作.

原文链接:https://www.f2er.com/csharp/99237.html

猜你在找的C#相关文章