【问题标题】:Multiple Mysql Connections from Docker -> Socket Error来自 Docker 的多个 Mysql 连接 -> 套接字错误
【发布时间】:2018-03-31 22:15:05
【问题描述】:

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

在每个控制台应用程序在具有自己的 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 的多个连接的连接存在问题。

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

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

问候 迈克尔

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-12
      相关资源
      最近更新 更多