@@ -443,7 +443,7 @@ public async Task ConnectAsync(ConnectionSettings cs, ILoadBalancer? loadBalance
443
443
payload = await ReceiveReplyAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
444
444
OkPayload . Create ( payload . Span , SupportsDeprecateEof , SupportsSessionTrack ) ;
445
445
446
- if ( ShouldGetRealServerDetails ( ) )
446
+ if ( ShouldGetRealServerDetails ( cs ) )
447
447
await GetRealServerDetailsAsync ( ioBehavior , CancellationToken . None ) . ConfigureAwait ( false ) ;
448
448
}
449
449
catch ( ArgumentException ex )
@@ -1311,10 +1311,20 @@ bool ValidateRemoteCertificate(object rcbSender, X509Certificate rcbCertificate,
1311
1311
// Some servers are exposed through a proxy, which handles the initial handshake and gives the proxy's
1312
1312
// server version and thread ID. Detect this situation and return `true` if the real server's details should
1313
1313
// be requested after connecting (which takes an extra roundtrip).
1314
- private bool ShouldGetRealServerDetails ( )
1314
+ private bool ShouldGetRealServerDetails ( ConnectionSettings cs )
1315
1315
{
1316
- // currently hardcoded to the version returned by the Azure Database for MySQL proxy
1317
- return ServerVersion . OriginalString == "5.6.26.0" || ServerVersion . OriginalString == "5.6.39.0" ;
1316
+ // currently hardcoded to the version(s) returned by the Azure Database for MySQL proxy
1317
+ if ( ServerVersion . OriginalString == "5.6.42.0" || ServerVersion . OriginalString == "5.6.39.0" || ServerVersion . OriginalString == "5.6.26.0" )
1318
+ return true ;
1319
+
1320
+ // detect Azure Database for MySQL DNS suffixes
1321
+ if ( cs . ConnectionProtocol == MySqlConnectionProtocol . Sockets && cs . HostNames ! . Count == 1 )
1322
+ {
1323
+ return cs . HostNames [ 0 ] . EndsWith ( ".mysql.database.azure.com" , StringComparison . OrdinalIgnoreCase ) ||
1324
+ cs . HostNames [ 0 ] . EndsWith ( ".mysql.database.chinacloudapi.cn" , StringComparison . OrdinalIgnoreCase ) ;
1325
+ }
1326
+
1327
+ return false ;
1318
1328
}
1319
1329
1320
1330
private async Task GetRealServerDetailsAsync ( IOBehavior ioBehavior , CancellationToken cancellationToken )
0 commit comments