来自Docker的多个Mysql连接 - >套接字错误

时间:2017-10-19 19:16:15

标签: c# mysql docker mariadb windows-server-2016

我目前正尝试从VM迁移到Docker Windows Containers。容器在Windows Server 2016 Datacenter上托管。操作系统安装在Hetzner托管的物理根计算机上。我的Docker容器包含一个用c#编写的控制台应用程序,可以在google-cloud中托管MariaDB数据库上的更新。

在每个控制台应用程序在具有自己的ipv4的分离VM中运行之前。现在,它们在容器中运行并获得以下异常

Unhandled Exception: System.TypeInitializationException: The type initializer for 'A.C' threw an exception. ---> MySql.Data.MySqlClient.MySqlException: Authentication to host '##.##.##.##' for user '####' using 
method 'mysql_native_password' failed with message: Reading from the stream has failed. ---> MySql.Data.MySqlClient.MySqlException: Reading from the stream has failed. ---> System.IO.EndOfStreamException: 
Attempted to read past the end of the stream.
   at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   --- End of inner exception stack trace ---
   at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket()
   --- End of inner exception stack trace ---
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.AuthenticationFailed(Exception ex)
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket()
   at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(Boolean reset)
   at MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset)
   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 ServiceStack.OrmLite.OrmLiteConnection.Open()
   at ServiceStack.OrmLite.OrmLiteConnectionFactory.OpenDbConnection()
   at A.C.b()
   at A.C..cctor()
   --- End of inner exception stack trace ---
   at A.C.A()
   at A.b..ctor()
   at A.a.A()
   at A.d.A(String[] )
   at A.d.a[A](String[] )
   at A.A.A(String[] )

Docker使用NAT网络。因此,我认为关于来自同一IP的多个连接的连接存在问题。

你们中的任何人都有类似的经历或知道如何解决这个问题吗?我有点卡住,很高兴得到任何帮助。提前谢谢。

如果您对我的设置或其他任何问题有任何疑问,请告诉我们。

此致 迈克尔

1 个答案:

答案 0 :(得分:0)

这似乎是MySql.Data中的常见问题;请参阅bug 76597末尾的Rui Fan的评论,以寻找潜在的解决方法。