Mysqlexception: Reading From the Stream Has Failed.
1. Groundwork
The following exception was found in our product deployment:
- MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host '172.16.0.203' for user '******' using method 'mysql_native_password' failed with message: Reading from the stream has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> Arrangement.IO.IOException: Unable to read data from the send connectedness: An established connexion was aborted past the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted past the software in your host machine
- at Organization.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
- --- End of inner exception stack trace ---
- at MySql.Information.Common.MyNetworkStream.HandleOrRethrowException(Exception due east) in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Information\common\MyNetworkStream.cs:line 95
- at MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count) in East:\GitHubRepos\mysql-connector-internet-oracle\Source\MySql.Data\common\MyNetworkStream.cs:line 112
- at System.Internet.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
- at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 outset, Int32 count, AsyncProtocolRequest asyncRequest)
- at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 beginning, Int32 count, AsyncProtocolRequest asyncRequest)
- at Arrangement.Cyberspace.Security._SslStream.ProcessRead(Byte[] buffer, Int32 first, Int32 count, AsyncProtocolRequest asyncRequest)
- at Arrangement.Net.Security.SslStream.Read(Byte[] buffer, Int32 commencement, Int32 count)
- at MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count) in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\TimedStream.cs:line 208
- at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
- at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count) in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\MySqlStream.cs:line 183
- at MySql.Information.MySqlClient.MySqlStream.LoadPacket() in Eastward:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\MySqlStream.cs:line 204
- at MySql.Data.MySqlClient.MySqlStream.LoadPacket() in E:\GitHubRepos\mysql-connector-internet-oracle\Source\MySql.Data\MySqlStream.cs:line 228
- at MySql.Information.MySqlClient.MySqlStream.ReadPacket() in East:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\MySqlStream.cs:line 143
- at MySql.Data.MySqlClient.NativeDriver.ReadPacket() in E:\GitHubRepos\mysql-connector-cyberspace-oracle\Source\MySql.Data\NativeDriver.cs:line 137
- at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket() in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\Authentication\MySQLAuthenticationPlugin.cs:line 171
- at MySql.Data.MySqlClient.Hallmark.MySqlAuthenticationPlugin.AuthenticationFailed(Exception ex) in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\Authentication\MySQLAuthenticationPlugin.cs:line 92
- at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket() in East:\GitHubRepos\mysql-connector-cyberspace-oracle\Source\MySql.Data\Hallmark\MySQLAuthenticationPlugin.cs:line 177
- at MySql.Data.MySqlClient.Hallmark.MySqlAuthenticationPlugin.Cosign(Boolean reset) in Due east:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\Authentication\MySQLAuthenticationPlugin.cs:line 131
- at MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset) in Due east:\GitHubRepos\mysql-connector-internet-oracle\Source\MySql.Information\NativeDriver.cs:line 505
- at MySql.Data.MySqlClient.NativeDriver.Open() in Due east:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Information\NativeDriver.cs:line 309
- at MySql.Data.MySqlClient.Driver.Open() in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\Driver.cs:line 240
- at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) in Due east:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Information\Commuter.cs:line 227
- at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\MySqlPool.cs:line 172
- at MySql.Information.MySqlClient.MySqlPool.GetPooledConnection() in Due east:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Information\MySqlPool.cs:line 155
- at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Information\MySqlPool.cs:line 244
- at MySql.Information.MySqlClient.MySqlPool.GetConnection() in E:\GitHubRepos\mysql-connector-cyberspace-oracle\Source\MySql.Information\MySqlPool.cs:line 257
- at MySql.Data.MySqlClient.MySqlConnection.Open() in E:\GitHubRepos\mysql-connector-net-oracle\Source\MySql.Data\Connection.cs:line 505
- at MySqlConsole.Program.Primary(Cord[] args) in E:\GitHubRepos\mysql-connector-internet-oracle\Samples\MySqlConsole\Program.cs:line 19
Our awarding contains an NTService and several IIS web sites. The .Net awarding runs on multiple windows servers (have 2012 and 2016). The MySQL database server runs on a carve up CentOS machine (172.16.0.203). We're using Connector/NET 6.ix.8.0 with MySQL five.seven.fourteen. The connection cord looks similar:
- server=172.16.0.203;database=MatchTiming;user=***;countersign=***;charset=utf8;
The exam lawmaking with the aforementioned issue looks like:
- try
- {
- using (MySqlConnection conn = new MySqlConnection(Properties.Settings.Default.ConnString))
- {
- MySqlCommand cmd =new MySqlCommand($ "SELECT ID,Proper noun FROM MatchTiming.`Match` LIMIT 0, x;" , conn);
- conn.Open();
- MySqlDataReader reader = cmd.ExecuteReader(Organization.Data.CommandBehavior.SingleResult);
- while (reader.Read())
- {
- Console.WriteLine(reader.GetString(1));
- }
- reader.Close();
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
two. Findings
Afterward some investigation, I take the following findings:
-
The exception doesn't occur on all the servers.
- Both NTService and IIS sites have this exception. So does a windows panel application.
- The exception will occur 100% on the commencement database connection attempt for every process/WebAppPool. Then the following database connections (in the same process/WebAppPool) tin be established successfully.
- The exception will be thrown about 15 seconds after the first database connection attempt. Looks similar a timeout issue.
- The exception is never seen in development environment.
- MySQL Workbench can encounter a connection with no username from the same IP address. Then it disappears after fifteen seconds.
- The servers with this exception don't have internet access.
Some similar MySQL bug reports are found but no consistant steps to repeat the exception. A number of workarounds were provided in the discussion. But the reason is still unknown.
- https://bugs.mysql.com/bug.php?id=76597
- https://bugs.mysql.com/bug.php?id=86056
I've tried all the following workarounds with no luck:
- Upgrading the Connector/Cyberspace to half dozen.9.9.0.
- Upgrading the MySQL Server to 5.7.19.
- Setup a new MySQL Server in the product environs.
- Use Percona MySQL Server instead of official MySQL Community.
- Supersede Oracle Connector/NET withAsync MySQL Connector for .Cyberspace and .Cyberspace Core (https://github.com/mysql-cyberspace/MySqlConnector)
In some perticular cases the issue got resolved with some of the workarounds but not my issue. Then I have to earn my own living.
3. Investigation
I dived into the Connector/NET source code (https://github.com/mysql/mysql-connector-net) and institute something interesting here:
https://github.com/mysql/mysql-connector-net/blob/5864e6b21a8b32f5154b53d1610278abb3cb1cee/Source/MySql.Data/NativeDriver.cs#L290
Line 309 is the source of exception. Only line 290-299 attracted me. It says the SSL is enabled by default. This is unexpected to me since I've never configured the SSL document. I don't need SSL because my product database servers are in a managed LAN without net access. Merely this gives me an important inkling. Then I found the server provided a cocky-signed SSL cert to the customer. The Windows PKI (Public Cardinal Infrastructure) API (Crypto API) volition validate the SSL cert immediately after it received the SSL cert from server. This self-signed cert is non in the certificate trust listing (CTL) past default. If the current CTL is likewise old, Windows needs to update the latest CTL from the internet. But this server doesn't take internet access.
Here comes the network packet capture:
The Wireshark capture confirms the above cert validation process. And this is the root crusade.
4. Solutions
Knowing the root cause, the solutions become like shooting fish in a barrel.
Solution 1: If SSL is not required. Since information technology is caused by SSL, nosotros can turn off SSL past appending " SslMode=None" to the connection cord.
Solution 2: If SSL is required, server identity is of import and needs to exist verified. The server needs a internet connection to do the cert verification. Delight annotation the crypto API doesn't update CTL for every procedure. The CTL is maintained at operating system level. Once you connect the server to internet and make an SSL database connection to the server, the CTL will be updated automatically. Then yous may disconnect the internet connexion. Notation once again the CTL has its expiration date and after that the Windows needs to update it once more. This will occur probably after several months.
Solution iii: If SSL is required but the server identity is not important. Typically SSL is just used to encrypt the network transport in this case. We tin plow off CTL update:
- Press Win+R to open the "Run" dialog
- Blazon "gpedit.msc" (without quotes) and press Enter
- In the "Local Group Policy Editor", expand "Figurer Configuration", expand "Authoritative Templates", expand "System", expand "Cyberspace Communication Direction", and so click "Cyberspace Communication settings".
- In the details console, double-click "Turn off Automatic Root Certificates Update", clickEnabled, then click OK. This change will exist constructive immediatelly without restart.
5. References
Configuring Certificate Revocation: https://technet.microsoft.com/en-us/library/cc771079(5=ws.11).aspx
How Document Revocation Works: https://technet.microsoft.com/en-united states of america/library/ee619754(5=ws.10).aspx
Windows XP: Certificate Status and Revocation Checking https://social.technet.microsoft.com/wiki/contents/articles/4954.windows-xp-certificate-status-and-revocation-checking.aspx
Should clients be able to access ctldl.windowsupdate.com when using WSUS? https://serverfault.com/questions/714637/should-clients-be-able-to-admission-ctldl-windowsupdate-com-when-using-wsus
An automatic updater of untrusted certificates is available for Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2 https://support.microsoft.com/en-us/help/2677070/an-automatic-updater-of-untrusted-certificates-is-available-for-window
Document Back up and Resulting Internet Advice in Windows Vista https://technet.microsoft.com/en-us/library/cc749331(v=ws.10).aspx
Clasificación de colinas
La idea básica del método de clasificación Hill es: primero seleccione el primer número entero y divida todos los registros del archivo para clasificarlos en grupos. Por ej...
Cadena-Air conditioning autómata-presión dp
La thought principal: Dadas las cadenas m 01, pregunte cuántas cadenas de palíndromo inverso 01 de longitud 2n contienen estas cadenas m. Una cadena 01 se llama anti-palíndromo si y ...
Semáforo
Semáforo Breve introduccion United nations semáforo Semaphore es un contador que controla el acceso a múltiples recursos compartidos. Al igual que CountDownLatch, es esencialmente un "Ce...
Hash Storage en Redis (3)
Esto es muy similar a HashMap en Java, por lo que es muy simple, es muy adecuado para almacenar un papel u objeto correspondientes, como la cuenta y la contraseña, la cuenta no permite duplicar...
recover/panic
El pánico detendrá el programa, con el fin de evitar que tales problemas causados por PANÁNT, debe sobrescribir el panico. El uso del dolor es: usado para lanzar un error. Recup...
Coffee Constructor relevent stuffs
Java Constructor relevent stuffs El rol de Constructor es estandarizar la plantilla al generar objetos usando una clase como plantilla ** 1. El papel básico del ejemplo del constructor. ** Si n...
¿Qué significa "Chmod 666?
Hoy, veré el puerto serie en el código fuente de Android. Hay un comando para ser Chmod 666. Sé que 777 está todo autorizado. El 666 no es mucho. Los resultados de la consu...
castillogovaland01.blogspot.com
Source: https://programmerclick.com/article/88112388277/
0 Response to "Mysqlexception: Reading From the Stream Has Failed."
Post a Comment