Hi,

I've sent a similar post earlier - but after no more luck and a lot more
frustration, I am reposting the issue with some additional information.

It's regarding several web applications on the same server, connecting to a
SQL Server on another server.

I keep getting the following exception when accessing the database:

-----
System.Data.SqlClient.SqlException: Timeout expired. The timeout period
elapsed prior to completion of the operation or the server is not
responding.
----

I am currently using the following code to connect, but I've had the same
problem with all the different code snippets I've tried, so I doubt the
problem lies herein:

-----
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
.... data code ....
connection.Close();
}
-----

The problem happens 1-5 times, after I refresh the page enough times, it
usually goes through. I've seen a number of potential solutions to the
problem - but none of them fits the problem.

I usually get the exception after not using the system for a while, but I
haven't experienced when the system is "in use", i.e. when the previous
request was no more than a couple of minutes ago, and no recompile of the
application has been done.

I _don't_ get enough connections to exceed the maximum - far from it (when I
don't get the exception, the connection pooling seems to work fine).

The exception is thrown instantly, not after the default 30 second timeout.

And after I had accidentally misconfigured the authentication in the web
application, the user didn't have access - I got "Login failed for user
(null)" - what's odd was that I _still_ got the "Timeout expired" exception
4-5 times before I finally got the expected "Login failed" exception. The
"Timeout expired" exception gets thrown even before I successfully connect
to the database!

Suggestions are very welcome, I've been struggling with this problem off and
on for several weeks now. It's only a big nuisance during development, but
naturally, it's a real showstopper for going into production with the
application(s).


Regards,
Nils Magnus Englund

RE: "Timeout expired" in ADO.NET by NoSpamMgbworld

NoSpamMgbworld
Tue Sep 27 07:27:03 CDT 2005

1. Make sure the connection timeout is large enough - this is not normally
the problem,however.

2. Make sure the command timeout is large enough for the work you are doing
- this is a common problem.

NOTE: I find it best to always explicitly set timeout values.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************


"Nils Magnus Englund" wrote:

> Hi,
>
> I've sent a similar post earlier - but after no more luck and a lot more
> frustration, I am reposting the issue with some additional information.
>
> It's regarding several web applications on the same server, connecting to a
> SQL Server on another server.
>
> I keep getting the following exception when accessing the database:
>
> -----
> System.Data.SqlClient.SqlException: Timeout expired. The timeout period
> elapsed prior to completion of the operation or the server is not
> responding.
> ----
>
> I am currently using the following code to connect, but I've had the same
> problem with all the different code snippets I've tried, so I doubt the
> problem lies herein:
>
> -----
> using (SqlConnection connection = new SqlConnection(connectionString))
> {
> connection.Open();
> .... data code ....
> connection.Close();
> }
> -----
>
> The problem happens 1-5 times, after I refresh the page enough times, it
> usually goes through. I've seen a number of potential solutions to the
> problem - but none of them fits the problem.
>
> I usually get the exception after not using the system for a while, but I
> haven't experienced when the system is "in use", i.e. when the previous
> request was no more than a couple of minutes ago, and no recompile of the
> application has been done.
>
> I _don't_ get enough connections to exceed the maximum - far from it (when I
> don't get the exception, the connection pooling seems to work fine).
>
> The exception is thrown instantly, not after the default 30 second timeout.
>
> And after I had accidentally misconfigured the authentication in the web
> application, the user didn't have access - I got "Login failed for user
> (null)" - what's odd was that I _still_ got the "Timeout expired" exception
> 4-5 times before I finally got the expected "Login failed" exception. The
> "Timeout expired" exception gets thrown even before I successfully connect
> to the database!
>
> Suggestions are very welcome, I've been struggling with this problem off and
> on for several weeks now. It's only a big nuisance during development, but
> naturally, it's a real showstopper for going into production with the
> application(s).
>
>
> Regards,
> Nils Magnus Englund
>
>
>
>
>
>

Re: "Timeout expired" in ADO.NET by Nils

Nils
Tue Sep 27 07:35:23 CDT 2005

Hi Gregory,

Thank you for your reply, but perhaps you didn't read the whole post? As I
mentioned, I get the exception instantly, no matter what the timeout values
are. Also, I get the exception before I would otherwise get the "Login
failed" exception.


Regards,
Nils Magnus Englund

"Cowboy (Gregory A. Beamer) - MVP" <NoSpamMgbworld@comcast.netNoSpamM> wrote
in message news:E135E651-DA94-4EB0-961E-712A69B47E4A@microsoft.com...
> 1. Make sure the connection timeout is large enough - this is not normally
> the problem,however.
>
> 2. Make sure the command timeout is large enough for the work you are
> doing
> - this is a common problem.
>
> NOTE: I find it best to always explicitly set timeout values.
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
>
> "Nils Magnus Englund" wrote:
>
>> Hi,
>>
>> I've sent a similar post earlier - but after no more luck and a lot more
>> frustration, I am reposting the issue with some additional information.
>>
>> It's regarding several web applications on the same server, connecting to
>> a
>> SQL Server on another server.
>>
>> I keep getting the following exception when accessing the database:
>>
>> -----
>> System.Data.SqlClient.SqlException: Timeout expired. The timeout period
>> elapsed prior to completion of the operation or the server is not
>> responding.
>> ----
>>
>> I am currently using the following code to connect, but I've had the same
>> problem with all the different code snippets I've tried, so I doubt the
>> problem lies herein:
>>
>> -----
>> using (SqlConnection connection = new SqlConnection(connectionString))
>> {
>> connection.Open();
>> .... data code ....
>> connection.Close();
>> }
>> -----
>>
>> The problem happens 1-5 times, after I refresh the page enough times, it
>> usually goes through. I've seen a number of potential solutions to the
>> problem - but none of them fits the problem.
>>
>> I usually get the exception after not using the system for a while, but I
>> haven't experienced when the system is "in use", i.e. when the previous
>> request was no more than a couple of minutes ago, and no recompile of the
>> application has been done.
>>
>> I _don't_ get enough connections to exceed the maximum - far from it
>> (when I
>> don't get the exception, the connection pooling seems to work fine).
>>
>> The exception is thrown instantly, not after the default 30 second
>> timeout.
>>
>> And after I had accidentally misconfigured the authentication in the web
>> application, the user didn't have access - I got "Login failed for user
>> (null)" - what's odd was that I _still_ got the "Timeout expired"
>> exception
>> 4-5 times before I finally got the expected "Login failed" exception. The
>> "Timeout expired" exception gets thrown even before I successfully
>> connect
>> to the database!
>>
>> Suggestions are very welcome, I've been struggling with this problem off
>> and
>> on for several weeks now. It's only a big nuisance during development,
>> but
>> naturally, it's a real showstopper for going into production with the
>> application(s).
>>
>>
>> Regards,
>> Nils Magnus Englund
>>
>>
>>
>>
>>
>>



Re: "Timeout expired" in ADO.NET by Marina

Marina
Tue Sep 27 08:41:29 CDT 2005

Does the problem go away if you use a different web server?

Does the problem go away if you use a different database server?

It's possible it's some sort of network or machine configuration issue. I
would experiment with using different machines as the web server and
database server, and trying to have the web server and database server be
the same machine.

"Nils Magnus Englund" <nils.magnus.englund@orkfin.no> wrote in message
news:%23bSe7y0wFHA.596@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I've sent a similar post earlier - but after no more luck and a lot more
> frustration, I am reposting the issue with some additional information.
>
> It's regarding several web applications on the same server, connecting to
> a SQL Server on another server.
>
> I keep getting the following exception when accessing the database:
>
> -----
> System.Data.SqlClient.SqlException: Timeout expired. The timeout period
> elapsed prior to completion of the operation or the server is not
> responding.
> ----
>
> I am currently using the following code to connect, but I've had the same
> problem with all the different code snippets I've tried, so I doubt the
> problem lies herein:
>
> -----
> using (SqlConnection connection = new SqlConnection(connectionString))
> {
> connection.Open();
> .... data code ....
> connection.Close();
> }
> -----
>
> The problem happens 1-5 times, after I refresh the page enough times, it
> usually goes through. I've seen a number of potential solutions to the
> problem - but none of them fits the problem.
>
> I usually get the exception after not using the system for a while, but I
> haven't experienced when the system is "in use", i.e. when the previous
> request was no more than a couple of minutes ago, and no recompile of the
> application has been done.
>
> I _don't_ get enough connections to exceed the maximum - far from it (when
> I don't get the exception, the connection pooling seems to work fine).
>
> The exception is thrown instantly, not after the default 30 second
> timeout.
>
> And after I had accidentally misconfigured the authentication in the web
> application, the user didn't have access - I got "Login failed for user
> (null)" - what's odd was that I _still_ got the "Timeout expired"
> exception 4-5 times before I finally got the expected "Login failed"
> exception. The "Timeout expired" exception gets thrown even before I
> successfully connect to the database!
>
> Suggestions are very welcome, I've been struggling with this problem off
> and on for several weeks now. It's only a big nuisance during development,
> but naturally, it's a real showstopper for going into production with the
> application(s).
>
>
> Regards,
> Nils Magnus Englund
>
>
>
>
>



Re: "Timeout expired" in ADO.NET by rviray

rviray
Tue Sep 27 10:48:18 CDT 2005


just to double check (don't want to offend)...your IIS server is on
Windows Server (NT, 2003, etc), and NOT testing on a workstatio
box...correct? Because there are limitations on a workstatio
environment. With that being said, have you tried to increase th
Connection timeout via the Connection String (Connection Timeout=30 <-
in seconds)...the default implied timeout is 15 seconds. Just a word o
warning, make sure the Connection Timeout value in the Connectio
string is appropriate for your environment, if set to a really hig
number, they could hang and not be put back in the Pool in a timel
manner.

Ralp

--
rvira
-----------------------------------------------------------------------
rviray's Profile: http://www.msusenet.com/member.php?userid=421
View this thread: http://www.msusenet.com/t-187108296


Re: "Timeout expired" in ADO.NET by Nils

Nils
Thu Sep 29 04:58:41 CDT 2005

A little addendum;

the first exception has the following stack trace:

----------------------
System.Data.SqlClient.SqlException: Timeout expired. The timeout period
elapsed prior to completion of the operation or the server is not
responding.
at System.Data.SqlClient.ConnectionPool.CreateConnection()
at System.Data.SqlClient.ConnectionPool.UserCreateRequest()
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString
options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open() at
(...)
----------------------

Consecutive exceptions have the following stack trace:

----------------------
System.Data.SqlClient.SqlException: Timeout expired. The timeout period
elapsed prior to completion of the operation or the server is not
responding.
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString
options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open() at
(...)
----------------------


After I refresh the page a couple of more times (each time I get the
exception with the latter stack trace), I finally get the site without any
exceptions.


Regards,
Nils Magnus Englund