-
Notifications
You must be signed in to change notification settings - Fork 347
-
Behavior
I've got a strange behavior on one of my systems. I am trying to connect to the mysql-server on a remote system. After 15 seconds (command timeout) I get a timeout exception. On the other systems which are likely the same, the same code works.
A closer look into the sent messages with wireshark shows that the Client(MySQLConnector) and Server (MySQL5.7) are giving each other Certificates, Handshakes and the "new session Ticket". But the Open method of the MySQLConnection-class does not continue.
Is there anything about the server configuration I forgot? Anything in the connectionstring I should add?
If you need furthermore Information let me know.
System Components
Both Systems are Windows 10.0.19043, x64 with an installed .NET Framework 4.8.04084
Remote Target MySQL Server:
- Version: 5.7.36
- Host OS: Ubuntu 20.04.3 LTS (by WSL)
Application:
- tested MySQLConnector Versionen 1.0.1.0 | 2.0
- Connectionstring: Server=xxx.xxx.xxx.xxx;Database=MySQL_TestDB;Port=3306;Uid=Username;Pwd=myPassword;
Exception
Message
Connect Timeout expired.
Inner Exception
Unable to connect to any of the specified MySQL hosts.
Stacktrace
at MySqlConnector.MySqlConnection.<CreateSessionAsync>d__117.MoveNext() in //src/MySqlConnector/MySqlConnection.cs:line 843\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in f:\dd\ndp\clr\src\BCL\system\runtime\compilerservices\TaskAwaiter.cs:line 184\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in f:\dd\ndp\clr\src\BCL\system\runtime\compilerservices\TaskAwaiter.cs:line 157\r\n
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()\r\n
at MySqlConnector.MySqlConnection.<OpenAsync>d__27.MoveNext() in //src/MySqlConnector/MySqlConnection.cs:line 407\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in f:\dd\ndp\clr\src\BCL\system\runtime\compilerservices\TaskAwaiter.cs:line 184\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in f:\dd\ndp\clr\src\BCL\system\runtime\compilerservices\TaskAwaiter.cs:line 157\r\n
at MySqlConnector.MySqlConnection.Open() in /_/src/MySqlConnector/MySqlConnection.cs:line 365\r\n
Code
C# console application:
MySqlConnection conn = new MySqlConnection(connectionstring);
try
{
Console.WriteLine(sw.Elapsed.ToString() + ": First Connection establish...");
conn.Open();
Console.WriteLine(sw.Elapsed.ToString() + ": First Connection established. State: " + conn.State.ToString());
conn.Close();
Console.WriteLine(sw.Elapsed.ToString() + ": First Connection closed. State: " + conn.State.ToString());
}
catch(Exception ex)
{
Console.WriteLine(sw.Elapsed.ToString() + ": Exception thrown:" + ex.Message);
}
Output:
00:00:00.0002621: First Connection establish...
00:00:15.0468347: Exception thrown:Connect Timeout expired.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 7 replies
-
A closer look into the sent messages with wireshark shows that the Client(MySQLConnector) and Server (MySQL5.7) are giving each other Certificates, Handshakes and the "new session Ticket".
Can you share a packet capture from a failing connection? Is it captured client-side or server-side? (Or do you have both?)
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes that's the expected behavior. The Server closes the connection due to the set timeouts. In this ws record the server closes the connection after 10 seconds when it is not used.
The Problem is, that 10 seconds before conn.Open(); does not continue after getting the "New Session Ticket" (913). Therefore I cannot continue in my code with a query execution or something like that.
This one is from a working system. It looks nearly the same until No. 336. (In this case I am connecting to a mysql version 8)
Beta Was this translation helpful? Give feedback.
All reactions
-
For the non-working scenario, does it help to set Ssl Mode=None on the client's connection string?
I'm wondering if it's some kind of problem negotiating TLS ciphers (yet one that doesn't result in an exception). You could try forcing TLS 1.2 with TLSVersion = TLS 1.2 (https://mysqlconnector.net/connection-options/#TlsVersion) or explicitly specify TlsCipherSuites (https://mysqlconnector.net/connection-options/#TlsCipherSuites). You can get the cipher suite from a working connection with SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME = 'Ssl_cipher';.
Beta Was this translation helpful? Give feedback.
All reactions
-
With SSL Mode=None, there is no error anymore.
TLS Version= TLS 1.2 does not help.
I will investigate more on the SSL Configuration.
Beta Was this translation helpful? Give feedback.
All reactions
-
Just to confirm: you're running Windows 10 21H1 on the client with .NET Framework 4.8? I'm not aware of any TLS negotiation problems associated with that platform.
Are there clients that can connect successfully to that server? Do they have a different client OS or .NET version?
Is it at all possible that you ever changed AppContext switches or registry values that affect TLS on the non-working client? https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls#configuring-security-via-appcontext-switches-for-net-framework-46-or-later-versions
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes its a Windows 10 Device, but LTSC and .NET Framework 4.8. I will check that TLS settings soon but that's already a good hint. Thanks a lot for your help!
The App Context is not switched. For testing purposes I just used a brand new .net 4.8 console application.
Beta Was this translation helpful? Give feedback.