I've had nothing but issues trying to get this site going. I have yet to see the front page. right now i've been stuck on timeout errors for the last two hours. I don't understand what I'm doing wrong. I'd read various threads on this site to get help,
and at this point I dont know if anything has helped because of the timeout error that I'm experiencing right now. The server itself is running, SQL is running, I don't know what else to check, I dont know what else to try, I dont know what else to do. I
apologize for sounding frustrated, but I really am. I didnt think I'd have this many problems. Can anyone offer any suggestions?
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Source Error:
Line 22: command.Connection = connection
Line 23: command.CommandType = CommandType.StoredProcedure
Line 24: connection.Open()
Line 25: filter = true
Line 26: If HttpContext.Current.User.IsInRole("Friends") Or HttpContext.Current.User.IsInRole("Administrators") Then
that's the first think I looked into. This is the snippet directly from my web.config file. I found alot of help from different posts around this forum in trying to make things work. I fear I'm missing a small detail somewhere, but I still havent found it
[:(]
I think perhaps the problem is the server itself? in the admin tool, I get a timeout message on the security tab as well:
There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page
where you can choose a new data store.
The following message may help in diagnosing the problem:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
EDIT: Ooops. That's what I get for not browsing the forums completely enough. I missed a post that already addressed this issue. Sorry if this was a redundant post.
--- original post ---
I've been having a similar problem. I don't get it immediately though. The site runs fine for a while, then after a bit I start getting the error. I've opened the Activity Monitor for SQL server and I see a LOT of connections in the Process Info view. They
are all owned by the ASPNET account. When I view details on them, they all indicate they were running the "Personal.dbo.GetPhotos" stored procedure. Has anyone dug into the code and found if there is someplace a connection isn't being closed where GetPhotos
is being called? I'm headed there next, but thought I'd pop the question in before I did because I may not get to it tonight.
I'll post more info if I find anything.
EDITED:
Ok, I dug in and found and hopefully fixed the issue. The PhotoManager class contained a private class member variable that was the SqlConnection. Not a big deal, but the problem was that everytime someone clicks a photo it creates a new PhotoManager which
creates and opens a new connection to the database. This works fine until you reach the maximum number of open connections you can have with whichever particular database you're using. I was able to click photos and watch in the SQL Server activity monitor
as more and more connections were created until finally I hit the max.
I fixed the problem by making the PhotoManager use a single static connection object. This may not be the optimum solution, but since the SQL access seems to be pretty fast, I don't think multiple users are going to notice a huge hit in performance if someone
else is also browsing photos. Of course, I also added the prudent thread locking code so there wouldn't be any issues with multiple users browsing at the same time.
Here are some of the sections I changed...
private
static
SqlConnection connection;
private SqlCommand command;
private bool filter;
public PhotoManager() {
if ( connection ==
null )
connection = new
SqlConnection(ConfigurationManager.ConnectionStrings["Personal"].ConnectionString);command
= new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.StoredProcedure;
lock (connection){
if (connection.State ==
ConnectionState.Closed){
connection.Open();
}
}
filter = true;
if (HttpContext.Current.User.IsInRole("Friends") ||
HttpContext.Current.User.IsInRole("Administrators")){
filter = false;
}
}
and one example of the locking in one of the methods
This was a really quick fix, and there's probably a better solution, but after making the changes I was able to browse photos to my heart's content and only had one connection created to my SQL Server.
Hope this helps!
We used to believe that a million monkeys typing on a million keyboards would reproduce the works of Shakespear. Now, thanks to the internet, we know this is not the case.
I'm getting a similar error message, but it's limited to the AddPhoto function. It's puzzling me because it was working and suddenly stopped, but even rebooting the server hasn't fixed the problem, which tells me it's not a resources issue. I can no longer
import a single photo into my site.
pcdebb
Member
108 Points
58 Posts
timeout errors
Jun 16, 2005 09:25 PM|LINK
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Source Error:
dejoie
Member
20 Points
4 Posts
Re: timeout errors
Jun 17, 2005 11:18 AM|LINK
Hello,
May be your connection string is not correct...
Regards.
pcdebb
Member
108 Points
58 Posts
Re: timeout errors
Jun 17, 2005 11:39 AM|LINK
<
connectionStrings><
add name="Personal" connectionString="Server=(local);Database=Personal;User ID=sa;Password=*" providerName="System.Data.SqlClient"/><
remove name="LocalSqlServer"/><
add name="LocalSqlServer" connectionString="Server=(local);Database=ASPNETDB;User ID=sa;Password=*"/></
connectionStrings>pcdebb
Member
108 Points
58 Posts
Re: timeout errors
Jun 17, 2005 11:53 AM|LINK
There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Psiberknetic
Member
5 Points
1 Post
Re: timeout errors
Jul 12, 2005 12:51 AM|LINK
--- original post ---
I've been having a similar problem. I don't get it immediately though. The site runs fine for a while, then after a bit I start getting the error. I've opened the Activity Monitor for SQL server and I see a LOT of connections in the Process Info view. They are all owned by the ASPNET account. When I view details on them, they all indicate they were running the "Personal.dbo.GetPhotos" stored procedure. Has anyone dug into the code and found if there is someplace a connection isn't being closed where GetPhotos is being called? I'm headed there next, but thought I'd pop the question in before I did because I may not get to it tonight.
I'll post more info if I find anything.
EDITED:
Ok, I dug in and found and hopefully fixed the issue. The PhotoManager class contained a private class member variable that was the SqlConnection. Not a big deal, but the problem was that everytime someone clicks a photo it creates a new PhotoManager which creates and opens a new connection to the database. This works fine until you reach the maximum number of open connections you can have with whichever particular database you're using. I was able to click photos and watch in the SQL Server activity monitor as more and more connections were created until finally I hit the max.
I fixed the problem by making the PhotoManager use a single static connection object. This may not be the optimum solution, but since the SQL access seems to be pretty fast, I don't think multiple users are going to notice a huge hit in performance if someone else is also browsing photos. Of course, I also added the prudent thread locking code so there wouldn't be any issues with multiple users browsing at the same time.
Here are some of the sections I changed...
private
static SqlConnection connection;private SqlCommand command;
private bool filter; public PhotoManager() {
if ( connection == null )
connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personal"].ConnectionString);command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.StoredProcedure;
lock (connection){
if (connection.State == ConnectionState.Closed){
connection.Open();
}
}
filter = true;
if (HttpContext.Current.User.IsInRole("Friends") || HttpContext.Current.User.IsInRole("Administrators")){
filter = false;
}
}
and one example of the locking in one of the methods
public
Stream GetPhoto(int photoid, PhotoSize size) {lock (connection)
{
command.CommandText = "GetPhoto";
command.Parameters.Add(new SqlParameter("@PhotoID", photoid));
command.Parameters.Add(new SqlParameter("@Size", (int)size));
command.Parameters.Add(new SqlParameter("@IsPublic", filter));
object result = command.ExecuteScalar();
try
{
return new MemoryStream((byte[])result);
}
catch (ArgumentNullException e)
{
return null;
}
}
}
This was a really quick fix, and there's probably a better solution, but after making the changes I was able to browse photos to my heart's content and only had one connection created to my SQL Server.
Hope this helps!
ersheido
Member
448 Points
117 Posts
Re: timeout errors
Jul 20, 2005 01:54 AM|LINK