I have a SQL Server with two databases, a production database and a development database. The .net 2.0 website hitting the production database with manual SqlConnection code is working fine. The other database is being hit from a newer ASP.NET MVC app using Entity Framework 6.2 and is getting timeout issues. The timeout takes 30 seconds the first time, but the page comes back almost instantaneously on subsequent refreshes. Both websites are on the same box as the database, so are only using "localhost" to connect. They are using SQL Server user logins, not Windows authentication.
I copied the .edmx and .tt files into a .net console app and that app has no problem hitting the database with the exact same linq query and pulling the same data that is failing.
I then created a new web site and copied just that same code into an aspx page. It fails the first time with a timeout, and then works on subsequent attempts (and a week ago, the main dev site was doing the same thing).
I separated the dev database from the SQL Server 2008 R2 server and attached it to a newly installed instance of SQL Server Express on a different port, and get the same results.
The web server is windows server 2008 standard 32-bit. I copied both websites and the console application to a new box (I thought was 2016, but it turns out it is 2008 standard 64-bit) and get the same results.
The dev site was working up until a couple of months ago. The client was using local user accounts for everything, but had a domain and wanted to do testing with windows authentication for an old vb app that hits the same database, and I had started migrating testing accounts to the domain. When the client tried to later, for an unrelated reason, change his password, we discovered that he was already using a domain account, but that his laptop could not connect to the domain. We found several other computers that could not connect, even though the machines I had connected to the domain during my testing were working fine. An outside network "friend" was brought in to figure out what was going on. At that point, I lost all track of what was actually done. I know that different network and domain configurations were tried and didn't fix the domain issues, but I don't know what. However, the production site was never rendered inoperative.
I have no idea what is going on. Does anyone else?
Oh, and in case it was a provider issue, I've also tried manual connection using OleDbconnection from the web app, and it also fails with the Timeout issue.
Update:
I spun up a new DataCenter 2016 box, installed IIS and .net on it and copied the website to that box. It has no problems hitting the database and pulling the data from the other server.
I know patches and such were updated on the original box while the domain and network were being manipulated, but I don't know how far behind they were. I suspect that some patch changed some default or inherited .net configuration options or something. I did do a "repair" on the .net installation, and that didn't make a difference. However, with the production site working fine, I'm not currently willing to uninstall .net or anything else. I'm afraid I would risk pushing this same error into the production site and the client would be screwed.
It seems that for some reason, the timeout period elapsed while attempting to consume the pre-login handshake acknowledgement.
Try increasing the connect timeout property in your connection string to 60 or more. Default is 15 (in seconds).
Example: Data Source=(LocalDB)\v11.0;Integrated Security=True;Connect Timeout=30
Related
Everything was working fine up to yesterday. VS2019. Net.Core 2.2 C#. Today I'm getting "This site cannot be reached" As far as I know I haven't changed any settings other than a routine Windows Update. I've read a fair few articles and nothing seems to work. Even a brand new web project with no changes has the same problem.
I get the same/similar no matter what browser I point at
I'm completely stuck. Does anyone have any ideas what it could be ?
Wierd!
To fix this all I did was connect to a local SQL database (on my machine) as opposed to a remote one (external server) and then delete all the cookies related to the localhost website.
It looks like some cookies get left laying around (from the external SQL) that affect IIS somehow, for any and all sites using SSL. Monitoring cookies I get around 7 created when I use the external SQL and only 3 when using the local.
Anyway, I just deleted all those cookies (localhost) because IIS still refused to work. I don't know why and I've just lost the entire day with this issue I may investigate another time but right now I need to crack on:(
I am developing razor pages web app that uses Microsoft entity framework that connects to SQL server. It all works in when running straight from visual studio (IIS Express), but when I tried to deploy it on IIS, SQL connection no longer worked.
connection strings i have tried:
Server=localhost;Database=zzzz;Trusted_Connection=True;
Server=DESKTOP-R7J0NGU;Database=zzzz;User Id=yyyy;Password=xxxx;
The application deployed on IIS does not give any information what is causing a problem, is it server, is it database, or authentication problem.
Any help is appreciated
Sorry to bother anyone.
the connection string has worked:
Server=DESKTOP-R7J0NGU;Database=zzzz;User Id=yyyy;Password=xxxx;
the problem was that the user "yyyy" did not have correct permissions to see and modify database tables. It did cost long time figuring out because my application in release build did not give any information as to why it might have failed.
I have some problems at the moment with an Applicaion of mine.
I got the task to create a Application for display stock data.
So i'd build a WinForm application with a local mdf Database.
The Application works great on my developer machine.
For the clients i've got some restrictions because of security reasons: I'm not allowed to install anything on the Client PC.
So after a long time of trail and error the application now starts on client PC. But the database connection will not work (db is local on Client).
The reason is that there are no SQL connectors installed on clients.
My questions is if there is any possibility to use SQLExpress or anything else without install on client?
(At the moment: providerName = "System.Data.SqlClient")
For the database Entity reference I use Telerik OpenAccess.
Thank u.
I am trying to solve the problem of very long response times from MySQL when opening a connection using the MySQL Connector for .net.
I have installed MySQL 5.5 running on an Azure VM (Server 2008) with --skip-name-resolve, and the database user accounts' host restrictions are using IP addresses. I am using the latest MySQL Connector for .net in my WCF service running on Azure (in the same location US- East, I have been using a trial subscription, no affinity set). My connection string in the WCF service is using the internal IP address of the VM hosting MySQL as the server parameter value. I also have "pooling = true;Min Pool Size=2;" just in case (I have tried without these parameters too).
When tracing the WCF the query response time once the service is running and processing requests are pretty good (even where each query result is unique and so not being cached) and I have no issues with the performance of MySQL providing it's getting hit frequently.
But the huge problem I haven't been able to crack is the length time it takes to get the connection to MySQL Open after no calls to the database have been made for about 3 or 4 minutes. If no database calls are made for a few minutes it takes 8 or 9 seconds or more to open the connection again. I wrapped the actual "conn.open();" with trace statements before and after calling, and this is the behaviour I am seeing logged time and time again after a few minutes of inactivity.
Incidentally, I have also tried (and still am using) the 'using' style of connection handling to ensure that the MySQL Connector is managing the connection pool.
e.g.:
using (var conn = new MySqlConnection(Properties.Settings.Default.someConnectionString)) { ... statements ..}
I feel like I have reached a dead end on this one so any suggestions would be greatly appreciated.
I can explain your question "the length time it takes to get the connection to MySQL Open after no calls to the database have been made for about 3 or 4 minutes. If no database calls are made for a few minutes it takes 8 or 9 seconds or more to open the connection again." why it happens:
The Windows Azure websites uses concept of hot (active) and cold (inactive) sites in which if a websites has no active connection the site goes it cold state means the host IIS process exits. When a new connection is made to that websites it takes a few seconds to get the site ready and working. While you have MySQL backend associated to this website, it take a few more seconds longer to get the requested served as there is some time taken by IIS host process to get started. That is the reason after few minutes of in activity the the response time is longer.
You can see the following presentation for more details on Windows Azure Hot (active) and Cold (inactive) Websites:
http://video.ch9.ms/teched/2012/na/AZR305.pptx
As this time, I am not sure and do not know how you can keep the websites always hot, even if moving to shared website or it is not possible at all. What I can suggest you to write your issue to Windows Azure WebSites Forum and someone from that team will provide you an appropriate answer.
I've been doing a little work with SQL Server and C# and every time I run the darn thing the connection times out unless I start services.msc and manually restart the service (SQL Browser Service). It's already set to automatic, does anyone know why it would do this? I'm not an advanced programmer, more of an intermediate one. Once I do restart this service it works fine as long as I keep using it. If I stop using it for more than 30 minutes I have to restart it again.
Have you checked the SQl Server Log and the windows event log?
Can you supply some more info., such as the C# code you are using to open/close the connection, the connection string etc.
Is autoclose kicking in?
Defaults to ON for SQL 2005 Express version, but it could have been set for other versions. The database should open automatically though...
Is it a query from the app that times out?
Or simply trying to connect to the server to run, say, SELECT ##SERVERNAME?
Can you connect to the SQL Server by name through SSMS without fiddling with the Browser service (I'm not even sure this really requires the Browser service depending on how you connect)? i.e. does it appear to be running fine except when your program causes it to crash? And once you've restarted it does it work fine repeatedly or do you have to keep restarting it as you use your program?
What version of SQL Server 2005 (and what service pack level) are you using?