Search code examples
c#mysql

MySql connection timeout - got timeout reading communication packets


I have 500 PCs that connect to MySql server. The most of them work fine except one group of approx 30 PC with weird behavior. They sometimes can connect to MySql a sometimes not. I use .NET 8.0 app and MySqlConnector.

dbConnection = new MySqlConnector.MySqlConnection(conString);
dbConnection.Open(); // exception here: "got timeout reading communication packets"

Both good and wrong captures are same up to ACK packet. You can see 10 sec delay in wrong attempt after ACK packet No. 249. I dont know what client waiting for because in good attempt there is no such delay after ACK packet No. 650 and client immediately send another packet.

Wrong attempt capture: wrong attempt capture

Wrong attempt log: wrong attempt log

Good attempt capture: good attempt capture

Good attempt log: good attempt log

The group of these PCs are behind one router but i dont know if this router can cause some problem because according to captures it looks that client causes delay


Solution

  • The 15 sec delay was caused by sslStream.AuthenticateAsClient() method in MySqlConnector (https://github.com/mysql-net/MySqlConnector/blob/72ee684ed0e04e5f39d6e0757a1963e4aa36807f/src/MySqlConnector/Core/ServerSession.cs#L1474). The client was trying for 15 sec to download CA certificates from ctldl.windowsupdate.com but there is all blocked on router (except MySql server). Meanwhile some 10 sec timeout reached on the server (see wrong attempt capture) and whole communication ended with error. As solution was installation of MySql certificate (exported from Wireshark capture) on all computers to Trusted Root Certification Authorities store so client is no longer trying to download CA certificates.