Irregular: SQL Connection Error: System.Data.SqlClient.SqlException (0x80131904)

0

I have a simple application that fetches entries from a few databases and then uses selenium to open a chrome window and paste information in a form. This agent runs once every five minutes.

I've looked through the logs and this error comes up now and then. When trying to find information about this problem the only "fixes" I can find is related to firewalls blocking ports or other issues that should be "persistent" like DB's not existing anymore / changed names or credentials.

The problem with my situation is that this error only happen on once or twice on some days, other days it never happens. If this was a problem with ports / DB names I would think this error should happen every time the agent runs. The agent runs 288 times a day, and like I mentioned, this only happens very few times in regards to the total runs of the agent.

I've come across an answer that suggests that this could be related to network issues on the host for the agent.

I would appreciate any ideas of what could cause this issue.

System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The specified network name is no longer available.) ---> System.ComponentModel.Win32Exception (0x80004005): The specified network name is no longer available at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) at …

c#
.net
sql-server
asked on Stack Overflow Mar 19, 2019 by Johannes B • edited Mar 19, 2019 by Johannes B

1 Answer

0

I think the reason can be found here

" the application is taking the assumption that the SQL connection is always available (no check or test before running commands) so when the line goes down or anything makes the connection drop/close the application produces that message.

To reproduce, simply kill the SQL session on the SQL server and you will get that very same a similar message."

Fix would be to add a check to make sure the connection can be made and add a retry / delay + retry

answered on Stack Overflow Mar 19, 2019 by Thomas Spankie

User contributions licensed under CC BY-SA 3.0