How to automate a db connectivity test to run at certain intervals - automation

I have an application that runs 24/7 and is connected to an sql database (sql server).
However, the application crashes most night with the following error message
*An existing connection was forcibly closed by the remote host.
*
the db resides on a different server than the application, so I first suspected a network connectivity issue that happened at night.
I ran a script overnight, to ping the db server every 5 minutes and tell me if there were such network connectivity loss, but over the course of 1 week, I only had 1 failed ping.
My next guess is that there could be a database connectivity issue, but i am not sure how I can automate a similar test on the database connection itself (I do not have access to the database server).
I created a UDL file, to test my connection manually (and that works fine), but I would like to such a test to run every 5 minutes overnight, and let me know in a log file, if and when the connection may have failed.
Thanks for your help!
ran script to test network connectivity overnight between appl and db server.
Network connection seems good 24/7 between the application and the db server.
I would now like to run a similar test at 1 or 5 minutes internals on the db connection itself, but I am unaware of how to do that.
I can test manually with a udl file, but I need to help to automate the test and output results in a log file.
Thanks

Related

Lock request timeout Exceeded

I have a dotnet exe app in a server which runs in sql server. during the factory production time my application were unable to connect to db for 1 to 2 minutes and then it gains connectivity at this unresponsive time when i accessed sql server management studio, i got the below error:
Taken from the answer over here.
This usually happens when there are too many open transactions that are blocking read access to your database server. You can try restart your server which will usually solve the issue.

How to prevent port timeouts for large remote queries from SQL Server?

I have an unixODBC connection from a linux-based SAP HANA database trying to pull massive amounts of data from another SQL Server 2012 database. Every now and then though I get "Login timeout expired" errors and I also notice via netstat that while the connection reaches "ESTABLISHED" status, it just closes out after about 10 seconds. The issue doesn't happen every time, and I've already done all kinds of due diligence on the network side and found no issues on that end.
Is there anything that can be done on the SQL Server configuration so that the connection doesn't time out?
The current remote query timeout is 600 seconds and remote login time-out is 30 seconds.
I also read in the following link that increasing "Connection timeout" setting in SQL Server helps but how do I change it, it's grayed out.
You are right to note that you need to change the remote query timeout setting to 0.
This link give pretty neat answer to your question. There are ways for doing it via both the SQL Server management Studio, and the command line. However, you need to first login with a user that has the required permissions.

Getting SqlException, Timeout error

I'm making a WPF application that is data driven and uses dynamic data. Now through the development process on my local computer, everything went fine, the application and my local sql server were functioning perfect.
Now what I did was transfer my database from my local machine to my server, By copying and pasting the database into the SqlServer DATA Folder on my remote server.
Now I'm able to connect to the server just fine, and i made sure to test the connection strings in Visual Studio to make sure it connects, and when i click "Test Connection" it says that the connection was successful.
But now when I try run the application, using the database that is located remotely, I get error:
Sql Exception, Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
And I find it strange because it was working fine 10 minutes ago on my local machine, so I think it must be a setting I have on my remote server or something?
Also I'm using LINQ to SQL, and I've even tried editing the LINQ to SQL Classes (dbml file) and increasing the timeout and such but still get the exact same error. I dont get what I'm doing wrong. Because the whole thing was working not too long ago on my local machine...
Any ideas what the problem is or how I could fix it?
Thanks
This error is generally due to Connection problem between server and the client. There may be a problem in network. Make Sure that database server is accessible from Application machine and no Firewalls are blocking the Connection.

How do I speed up my application connecting to MS SQL Server?

I have a Delphi application running on SQL Server 2000, but it's taking awfully long to connect to the database!
But when I run this application on my development server it connects pretty fast!
I am running on Windows 2003 server, SQL Server 2k personal edition, when I look on my MDAC version in the registry, I see version 2.8 already installed!
Any ideas why this happens on the production machine but not on the development machine?
There's a reasonable chance that this is down to a network level issue connecting to the database. Depending on whether you're running the application and database on the same box of course.
Try connecting to the database from the same machine using a different tool. You could set up a data source and test it from the control panel as an alternative. If the connection is slow from another tool test the connectivity between the servers for other types of connection (e.g. run a ping). It may be that it's resolving the server via broadcast rather than the domain, for instance. Or any number of other issues - firewall, switch, wins etc.
If you are connecting using integrated authentication also ensure that the database can resolve the application server as well as vice versa. This is part of the authentication process and I've seen it cause slow downs in creating database connections before.
In short, I'd be confident that this isn't a problem specific to delphi / sql, but something in the communications between your production servers.
Good luck!
Keep your connection open once you have established it. This is called connection pooling and will improve performance. I have no clue how to do it with a delphi application.
Your problem most likely is network or transport layer related
Are you connecting through TCP, Named Pipes or another mechanism?
Have you tried tracing opening a connection with Microsoft SQL Profiler?
regards,
Lieven
I had a problem a long time ago like this, and it came down to the workstation section of the connection string. its possible if you've copied the connection string from your dev machine that the workstation parameter is still in the connection string and pointing to your dev machine which probably does not exist on your deployment network.
In this case your connection to the database has to wait until the network tries to connect ot a non-existant machine (which obviously takes time). Remove the workstation cluse and it will speed up no end.

Sql 2005 Express edition slow connections

I'm running SqlServer 2005 express edition on my laptop for development purposes. It seems that when I open a connection to the database, the setup time is REALLY slow. It can take up to 10 seconds to get a connection. I usually have multiple connections open at the same time (Profiler, Development environment, Query Analyser, etc.) I have a hunch that the slow times are related to the fact that I have multiple connections open.
Is there a governor in Express edition that throttles connection times when multiple connections are made to an instance?
Update:
My workstation is not on active directory, and SQL is running mixed mode security. I will try the login with sql authentication. I am not using user instances.
Update2:
I setup a trace to try and figure out what is going on. When the connection to the database is opened the follow command is executed:
master.dbo.sp_MShasdbaccess
This command takes 6 seconds to execute.
I figured it out. The problem was I had multiple databases with AutoClose set to true. I shut it off in all my databases and the problem went away.
see this article for more info.
Are you sure the connection is the bottleneck? Is it your conn.Open() line that is taking 10 seconds?
AFAIK there's no governer anymore in SQL Express.
Now, are you on a Windows Active Directory Domain? If so, there might be an issue with your DNS or something that means the connection to the domain controller to validate your logon to the server instance is taking the time. I suggest you experiment switching the server over to use SQL Security, give the SA account a password, and try logging in as SA and see if that makes a difference.