Closed jonathanpeppers closed 3 months ago
devmartin Could not get this to work with Android API 33 (emulator or physical device).
DangerousTrustProvider register is being called.
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
This is to an AWS RDS instance. SSMS connects fine with encrypt true or false.
We cannot do this on user's phone. You do not have to install cert on android (it is embedded in the app itself).
I tried MAUI with .NET 8 and I am not experiencing the original issue anymore "SQL Server pre-login handshake failed". Now I only have "TrustServerCertificate=True" in my connection string.
For context I tested this using android 9, 10, 11, 12 and 13 using SQL Server 2019 + 2022, Microsoft.Data.SqlClient 5.1.2, VisualStudio 2022 17.8.1
I tried MAUI with .NET 8 and I am not experiencing the original issue anymore "SQL Server pre-login handshake failed". Now I only have "TrustServerCertificate=True" in my connection string.
For context I tested this using android 9, 10, 11, 12 and 13 using SQL Server 2019 + 2022, Microsoft.Data.SqlClient 5.1.2, VisualStudio 2022 17.8.1
Thank you for the info. It seems that in Microsoft.Data.SqlClient 5.1.2 it is solved.
I discovered one more problem on Android. Reported it but for now there is no progress on this. On ANDROID first connection open is 10 times slower than on windows. https://github.com/dotnet/SqlClient/issues/2193
Hope someone will take this as a priority because this is still not usable if connection "dies" and needs reopen, or we need a new connection object it will be slow on first open.
Closing as resolved as per above comments.
Issue moved from dotnet/maui#6859 Issue moved from https://github.com/xamarin/xamarin-android/issues/6990
From @janseris on Thursday, May 5, 2022 12:39:34 PM
Description
SQL Server - the connection was established but pre-login handshake failed when calling database via Entity Framework
**Microsoft.Data.SqlClient.SqlException:** 'A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)'
What does not help:
Encrypt=false
in connection stringEncrypt=true
in connection stringEncrypt=false;TrustServerCertificate=true;
in connection stringThe same works without any issue on Android 9 and up (both emulator and real device). Tested: works on Android 9 for all TLS settings:
Native TLS 1.2+
andManaged TLS 1.0
and also for"no option"
.The issue is in Debug (and thus probably also in Release) configuration.
Output for Android 5 (API 21):
Microsoft.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)'
Output for Android 8, for all TLS configuration options:
Native TLS 1.2+
andManaged TLS 1.0
and also for"no option"
.Similar issues: https://github.com/dotnet/maui/issues/3522
Steps to Reproduce
call database in a MAUI app with Android 8.1 or lower
Version with bug
Release Candidate 2 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 8.1 and below
Did you find any workaround?
no
Relevant log output
No response