Application has intermittent connection errors when connecting to SQL Server - sql-server

We have an MVC4 application hosted on a VM server that uses an entityframework style connection string to connect to an instance of SQL server hosted on another VM server on the same ESX host, both are also on the same subnet IP address range i.e. 172.16.164.XX. The problem we are encountering is that if the application has not been used by users for a short while and a user then attempts to access the application, the user will fail to connect to the db to retrieve data. They will attempt a number of times and eventually the application will successfully connect to the DB and the application can be used without any issues or connection failures.
These are the typical errors returned by the application...this is what was recorded in the logs when I attempted to login today (this happened about 9 times before success):
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: 0 -
The specified network name is no longer available.) --->
System.ComponentModel.Win32Exception (0x80004005): The specified
network name is no longer available
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: Named Pipes Provider, error: 40 - Could not open a
connection to SQL Server) ---> System.ComponentModel.Win32Exception
(0x80004005): The network path was not found
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
We thought it could have something to do with our DNS server but we have added the SQL server IP address and host name to the host file on the application server. We have also added the SQL server IP address to the connection string in the web.config, but this behavior persists. Any help or suggestions appreciated -we are really struggling to find a solution to this issue

Related

ADF Copy Actitity issue

I have an issue where I can preview data from a source, a SQL Server connected through a Self-Hosted IR, but I cannot copy the data to a sink (Azure SQL DB on an EP).
The user account at the SQL Server level has access to the relevant tables, as can be verified by the fact that I can preview data. The sink side dataset also works, as I can use with similar data sources to the source.
If I, for example, try to fetch two specific rows, I can see them in the preview, but it takes 5 minutes for ADF to give an error message which is wildly misleading:
ErrorCode=SqlFailedToConnect,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Cannot connect to SQL Database: 'ServerName.database.windows.net', Database: 'DatabaseName', User: 'AdminUserName'. Check the linked service configuration is correct, and make sure the SQL Database firewall allows the integration runtime to access.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Data.SqlClient.SqlException,Message=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 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.),Source=.Net SqlClient Data Provider,SqlErrorNumber=10060,Class=20,ErrorCode=-2146232060,State=0,Errors=[{Class=20,Number=10060,State=0,Message=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 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.),},],''Type=System.ComponentModel.Win32Exception,Message=A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond,Source=,'
What am I doing wrong? Is there some setting I am missing?
Please check whether the Azure SQL DB(sink) is accessible from the server on which you have installed the self hosted IR.
YOu would need to whitelist the IP of the Self IR server in Azure SQL DB firewall rules and make some port opening in the IR server for Auzre SQL DB to be accessible.
Basically in case if an IR is being used in a copy activity, both the source and sink must be accessible from the server on which IR is set up

Connection to Azure Managed server fails from .NET app but works when connection from the command line

I am trying to connect from an Azure virtual server (windows 10) to an Azure Managed SQL instance.
From the command line on the virtual server I can connect to the managed SQL instance using:
sqlcmd -S aserver-data01.public.abc123.database.windows.net,3342 -U User01 -P password
This connects fine.
I am running a compiled .NET executable on the same virtual server that attempts to connect to the managed SQL server using the following connection string:
DataBaseConnectionString, Data Source=aserver-data01.public.abc123.database.windows.net,3342; Database=MyDB; Integrated Security=false; User ID=User01; Password=password
It fails with:
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 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) ---> System.ComponentModel.Win32Exception (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Can anyone help, I can't seem to get it to connect.
The problem was the .net executable was pulling the connection string from a comma separated config file and so was splitting the connection string in half at the comma before the port number.

Can't Connect to Azure Server from SQL Server

I can't connect SQL Server to Azure. When I try to connect I get this error:
How can I solve this?
Connect to Server
Cannot connect to mukdo.database.windows.net.
ADDITIONAL INFORMATION:
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 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (Microsoft SQL Server, Error: 10060)
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Make sure your IP is added in the firewall setting in Azure SQL. You can use 'Add client IP', if it's not added.enter image description here
My problem Solved After Change My Internet Connection

SQL Server not connecting to specific network

I can connect without any problem to my Sql Server (network service) at home or anywhere else except at work. Sometimes it gets a spirit of the moment connection and then just disconnects again.
It keeps giving me this error:
==========================================================================
Cannot connect to winsqls02.cpt.wa.co.za.
==========================================================================
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: Named Pipes Provider, error: 40 -
Could not open a connection to SQL Server) (.Net SqlClient Data Provider)
--------------------------------------------------------------------------
I have tried restarting my laptop, pinging the server, changing to another router at work, but nothing seems to work.
Is there maybe a simple reason for this issue, because I can't seem to find any answers on the internet.

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

In my remote server I log in SQL Server with SQL Server Management Studio. It works.
But on my PC when I try to log in I get an error. I add port to server name but I still get the same error. My TCP/IP is enabled. Port is enabled
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 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (.Net SqlClient Data Provider)

Resources