-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL Server pre-login handshake failed Android 5,6,8.1 #6990
Comments
Issue moved from dotnet/maui#6859
From @Redth on Thursday, May 5, 2022 1:25:46 PM Generally best practice would be to not connect directly to a database from a mobile application where you'll risk the server credentials being discoverable. Aside from that, @jonpryor any ideas? |
Issue moved from dotnet/maui#6859
From @drasticactions on Thursday, May 5, 2022 2:37:53 PM This won't be MAUI specific in any case, right? Like with that other issue linked, this stack is entirely Android and that would point to it being a net6-android issue (or at least something you need to change at a project level). |
Issue moved from dotnet/maui#6859
From @Eilon on Thursday, May 5, 2022 5:17:18 PM Should we move this to the xamarin-android repo? |
Issue moved from dotnet/maui#6859
From @Redth on Thursday, May 5, 2022 8:19:42 PM I'll let @jonpryor handle moving and closing as necessary. Unfortunately we can't move issues across orgs with GitHub, it has to be 'manually' moved. |
Issue moved from dotnet/maui#6859
From @Eilon on Thursday, May 5, 2022 9:39:45 PM I have magic tools that can do this (it just automates the manual steps using APIs). |
@Eilon Hi, please, is there any update on this or anyone assigned to solve this issue or anything I can do to help? Repro project: Note: a connection string needs to be provided into the DbContext (both in Debug Android 8.0:
|
@janseris sorry this is not an area I'm familiar with at all. @jonathanpeppers - do you know who could look at this or what milestone it might get slotted into for investigation? |
@janseris I am not getting the same error using the sample project above. Does this app talk directly to a database? I wouldn't recommend doing this in a mobile app -- security best practice would be to put a web service in between. To look into this further, I think we need adb logcat output of the full exception. Depending on what is wrong, we might need someone from the Mono runtime team to look into this. Thanks! |
@steveisok there is a partial stack trace above, should |
Thanks. I get the error in every MAUI app talking to external sql server on Android 8.1 and lower for me. There is no specific code needed. Yes the situation is db call from Android to SQL Server. The db communication works well on Android 9 and higher. BTW make sure there is a connection string to a valid SQL server to reproduce the issue. Otherwise invalid host name SqlException is received instead. I tried to capture the whole stack trace which is not my code. Is there any important part missing which I should add? My SQL Server version is 2012. Do you think that might be the issue? But it communicates with any Windows PC without any issues. I will try get output from adb logcat tomorrow. |
Yes, since I do not have a SQL Server to interact with, I just ran the sample as-is. |
I read here netty/netty#4718 that the issue might be that different implementations of SSL communication is used in different version of Android. Some of them tolerate multiple handshakes started and the one here throws an exception in that situation. netty/netty@446f7fd I however don't know what to do about it.
log.txt Android 8 emulator Comment on the content of the log:
The log is long because I don't know how to cut old info. When I run And I think that the reason that specifying |
Hi @Eilon. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you. |
@Eilon @jonathanpeppers I provided required info. |
@janseris sorry about that. I think the MsftBot got confused because in this bug I am the original opener (I copied the bug from the other repo), so even though you did reply, the bot saw that I didn't respond after a few days of the |
Hi @jonathanpeppers, is there any news on this issue, please? (older Android phones used periodically for technical inspections of appliances and facilities in industry - engine rooms, health care - engine rooms etc. and construciton sites) Developers in the repo I linked to - "netty" - did just a small and effective fix to solve this - they essentially put an Thank you. |
@jonathanpeppers I feel like this issue might belong over in https://github.com/dotnet/SqlClient. At least to start. |
Closing in favor of: dotnet/SqlClient#1656 I wish we could have just moved this issue around until we got it at the right place. Thanks! |
Issue moved from dotnet/maui#6859
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:
dotnet/maui#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
The text was updated successfully, but these errors were encountered: