Connect to mirror databases after failure

I have two mirrored SQL servers (e.g. A and B). I wrote a simple C # program (connect via SqlConnection) that insert rows into a DB. When I make the transition to server A, the program throws an exception, then I try to connect and get an exception by timeout ( **A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0**).

When you restart the application, the connection was successfully established (to server B). Then I switch to another server B and exclude the program exception, then I try to restore the connection, and its work is to connect to the witout restart program.

My connection string:

Data Source=SERVER_A;Failover Partner=SERVER_B;Initial Catalog=TEST_DB;persist security info=True;user id=USER_LOGIN;password=USER_PASS;Connection Timeout=60;

I am also trying to set a large timeout (60 seconds) and try to clear all sqlconnection pools, clear one pool on the connection, but it does not work.

Interesting fact: if I use the login and password for the domain, everything works fine! (User SID are the same)

+4
source share
1 answer

It's hard to say what your exact problem is. Perhaps this recovery failure is not instantaneous and cannot convey the status of the request - see https://dba.stackexchange.com/questions/27528/can-availability-groups-provide-seamless-failover-with-no-query-failures . If your application immediately repeats the request, then when recovering from a node failure, it may still be in the capture process and therefore not ready to accept connections.

0
source

Source: https://habr.com/ru/post/1546961/


All Articles