EFCore MAC - Unable to find an entry point named 'AppleCryptoNative_SslCreateContext' - ef-core-2.1

when running
dotnet ef database update --startup-project ../webapi/webapi.WebAPI.csproj
on my MAC 10.13.5
I get this error -
System.Data.SqlClient.SqlException (0x80131904): 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) ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.EntryPointNotFoundException: Unable to find an entry point named 'AppleCryptoNative_SslCreateContext' in shared library 'System.Security.Cryptography.Native.Apple'.
at Interop.AppleCrypto.SslCreateContext(Int32 isServer)
at System.Net.SafeDeleteSslContext.CreateSslContext(SafeFreeSslCredentials credential, Boolean isServer)
at System.Net.SafeDeleteSslContext..ctor(SafeFreeSslCredentials credential, SslAuthenticationOptions sslAuthenticationOptions)
at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteContext& context, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, SslAuthenticationOptions sslAuthenticationOptions)
--- End of inner exception stack trace ---
...
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)
I originally thought this was my local docker database was not available but when connecting to new database instance it still occurs, this was working yesterday.

Whilst typing this I came across this, but thought would just add the answer as someone on a MAC EF Core install may miss that also when searching -
A connection was successfully established with the server, but then an error occurred during the pre-login handshake
Cleaning my project (I personally deleted all the folders) and rebuilding, sorted it!

Related

connect asp.net to mysql on linux error of connection

i can't hosting to connect to mysql database on linux i have this error message :
Unable to connect to any of the specified MySQL hosts
i need your help thx; this is my code
I suspect this message came from an exception thrown by your con.Open() call. The message means your attempt to Open() the connection failed because Connector/Net (the .net driver for mySQL) couldn't find the server you asked for. (Never mind the pluralization in "any of the specified MySQL hosts" ; that is for a loadbalancing / failover feature you're probably not using.)
If it took a few seconds for con.Open() to throw the exception, that means there was a timeout. That means the host at x.x.x.x did not respond at all, probably because it's not there or behind a firewall. If you're trying to connect from your home or office to a MySQL server at a hosting service, you may need to go into the hosting service's control panel and whitelist your own machine's IP address.
If Open() threw its exception quickly, it means the host is there, but it is not running a MySQL server.
Pro tip: Always wrap your Open() calls in their own try{}catch(){} clauses; failed database connection attempts are not an unexpected occurrence. Here is an explanation.

Authentication mysql to .Net

I have Mysql DB connected to .NET MVC. When i connect remote it some times works fine and some times i have this error msg:
MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to
host 'ServerName' for user 'UserName' using method
'mysql_native_password' failed with message: Reading from the stream
has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005):
Reading from the stream has failed. ---> System.IO.IOException: Unable
to read data from the transport connection: An established connection
was aborted by the software in your host machine. --->
System.Net.Sockets.SocketException: An established connection was
aborted by the
Please how can i make Authentication ? Any ideas to solve it?
This is a common error when some kind of deadlock occurs on the database more commonly a connection has been open a long time and gets shut down at the database end even though it is still in-use in your web application.
In my code, I used a suggestion from Microsoft, that retries the database command if it fails. The link is here: http://social.technet.microsoft.com/wiki/contents/articles/4235.retry-logic-for-transient-failures-in-windows-azure-sql-database.aspx Similar things exist for other non-Azure problems that use RetryPolicy.
What this means in a simple (Azure in my case) example is:
private static RetryPolicy<SqlAzureTransientErrorDetectionStrategy> retryPolicy = new RetryPolicy<SqlAzureTransientErrorDetectionStrategy>(new Incremental(3, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)));
// Inside your database function
retryPolicy.ExecuteAction(() =>
{
db.ExecuteStoredProc("procRecordMetric", cmd);
});
In my case, this was caused by ssl being enabled on the mysql server.
Here is a snippet from my.cnf
#ssl-ca = /etc/ssl/mysql/ca-cert.pem
#ssl-cert = /etc/ssl/mysql/server-cert.pem
#ssl-key = /etc/ssl/mysql/server-key.pem
Commenting these 3 lines fixed the issue for me.

MSTest error - MySQLConnection aborts connection after upgrading to Connector 6.6.6

My database is MySQL 5.5.34 and I'd been using the MySQL Connector.NET version 6.5.4.
After uninstalling the 6.5.4 and installing version 6.6.6, I'm having issues with the connection aborting. The relevant code, which looks essentially like the following worked fine prior to the upgrade.
MySqlConnection connection = new MySqlConnection("server=localhost;port=7654;uid=matt;pwd=password");
connection.Open(); // this results in the exception
This works fine when I do this in a simple console application but does not work in my MS Test
The Exception I get is:
MySql.Data.MySqlClient.MySqlException: "Authentication to host 'localhost' for user 'matt' using method 'mysql_native_password' failed with mesage: Reading from the stream has failed"
Drilling down into the exception, the Inner Exception is "Unable to read data from the transport connection: An established connection was aborted by the software in your host machine."
I've tried with both VS 2010 and VS 2013. Same error for both.
Ideas?

Intermittent SQL Server Connection Issue

I have been experiencing an intermittent SQL connection problem that I can't resolve. First of all I will explain the setup:
Windows 2008 R2 Standard SP1 (and all patches delivered through windows update):
This server runs IIS 7.5
The ASP.NET MVC 4 Web App runs within it's own App Pool
The App Pool identity is used to set permission on the folder containing the code
The Web App passed a username and password in the connection string - server xxx; database=xxx; Persist Security Info=True; User ID=xxx; Password=xxx; Pooling=False; Network=DBMSSOCN;
elmah used to log errors
Windows 2008 R2 Standard SP1 (and all patches delivered through windows update):
This server runs SQL Server 2008 R2 Web Edition SP2
TCP/IP is the only enabled Client Protocol
These are VM's hosted by our cloud provider. The cloud provider has investigated, from an infrastructure point of view, but cannot find any problems.
The error messages generated are as follows:
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 9 - Associating port with I/O completion mechanism failed)
I've been unable to find any information on error code 9.
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - An operation was attempted on something that is not a socket.) ---> System.ComponentModel.Win32Exception (0x80004005): An operation was attempted on something that is not a socket
While these errors are generated, IIS will show the 'friendly error' page. It usually takes around 15 minutes for the issueto resolve itself or an IISReset. When this issue first occurred I downloaded a SQL Load Generator from codeplex and ran test up to 300 simultaneous connections with multiple query's and everything was ok. I also ran another test while the web app was generating the SQL exceptions - all connections from the load test succeeded. This really confused me!?!
No Event Logs are created during the outage.
To me the error message indicates a problem connecting to the SQL box, however the load test run during the most recent outage contradicts this - yet IIS is still serving content (configured error message).
I realize that this is a difficult question, however I would be very grateful for any advice regarding techniques to find the cause of the error. Any information on what error 9 relates to would also be helpful.

Issue with Azure Emulator and SQLLOCALDB

When in try to start azure storage emulator i get the following error.
Caught exception while probing for SQL endpoint. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Number of Sql Errors Reported: 1 Sql Error: System.Data.SqlClient.SqlError: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
All the Components have been correctly installed .
Kindly Help
Thanx
I managed to fix it by deleting and creating my LocalDb instance. In my case it happened because I installed Azure SDK 2.2 over version 2.1.
The step-by-step to fix it:
Run sqllocaldb i to get your instance name:
C:\Users\myUser>sqllocaldb i
v11.0
Stop LocalDB instance:
C:\Users\myUser>sqllocaldb p v11.0
LocalDB instance "v11.0" stopped.
Delete your LocalDB instance:
C:\Users\myUser>sqllocaldb d v11.0
LocalDB instance "v11.0" deleted.
Create your LocalDB instance with the same name:
C:\Users\myUser>sqllocaldb c v11.0
LocalDB instance "v11.0" created with version 11.0.
Delete database files to allow emulator to recreate db files
C:\Users\myUser\DevelopmentStorageDb22.mdf
C:\Users\myUser\DevelopmentStorageDb22_log.ldf
That should fix your issues.
It looks like your windows account under which you logged in is not sysadmin in sqlexpress instance. Normally emulator uses database within sqlexpress with windows authentication.
The first time you run the Windows Azure storage emulator, an initialization process runs to configure the environment. By default, the initialization process creates a database in SQL Express LocalDB. So, please make sure that your SQLExpress service is running and your login have sufficient rights to use the database within SQLExpress.
If you want to make use of a local instance of an SQL Server to be used by Storage Emulator follow steps listed at http://msdn.microsoft.com/en-us/library/windowsazure/gg433134.aspx.
HTH
Sameer
What i am suspecting is that your LocalDB configuration with emulator is somehow corrupted or misconfigured.
Please follow the blog below to see if you can verify LocalDB instance is ready/working and it is used by Emulator:
http://blogs.msdn.com/b/avkashchauhan/archive/2012/07/10/windows-azure-sdk-1-7-storage-emulator-and-localdb.aspx
If you still have problem the easiest method would be to uninstall SDK 1.7 completely and re-install which will fix any issue with your configuration rather the finding the problem and try to fix which could take longer.
I was getting a similar message:
Probing SQL Instance: 'localhost\SQLExpress'.
Caught exception while probing for SQL endpoint. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Number of SqlErrors Reported: 1
SqlError: System.Data.SqlClient.SqlError: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
No available SQL Instance was found.
One or more initialization actions have failed. Resolve these errors before attempting to run the storage emulator again.
Error: No available SQL Instance was found.
For me the problem was due to the fact that I was not running with administrator privileges.
Might be a little late to the party here, but I've seen this happen if you clear out or remove items in your "C:\Users[USER_NAME]\AppData\Local\Temp" folder.
At the time of writing this, Azurite is the replacement for "azure storage emulator". In my case, I was able to simply follow the steps here https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=npm#install-azurite to get it installed, and you should be good to go after that.