locked
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

    Question

  • I am using .net 2.0 ,MS Data access block to manipulate data and SQL server 2005 for data storage.

    I am calling 4 functions to access data while loading UI Form. On function 3 I got error “Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding”.

    Interesting thing is that it occurs occasionally (once in more the 1000 calls, my idea), not every time. Connection time out value, network configuration (TCP/IP) and other things are ok.

    If anyone has solution/suggestion please send it.

     

     

    Wednesday, August 08, 2007 8:38 AM

Answers

  • Hi Zeeshan,

     

    Based on your post, the error occurs when the execution time beyond Timeout Property. When you are trying to connect or access to a Database table which is having large volume of data, query execution time will be more. There are two main Timeout property in ADO.NET.

    1. Connection Timeout for Connection. It could be solved by setting ConnectionTimeout property of Connection object in Connection String.
    2. Timeout for Data access ( Command Object ). You can set
    CommandTimeout property to Command object. I recommend you set CommandTimeOut property to bigger one value. Try this. Please let me know whether this can handle this problem or not. If you have any further questions, please feel free to let me know.

     

     

    Thanks for your questions.

     

     
    Monday, August 13, 2007 8:09 AM
    Moderator

All replies

  • Hi Zeeshan,

     

    Based on your post, the error occurs when the execution time beyond Timeout Property. When you are trying to connect or access to a Database table which is having large volume of data, query execution time will be more. There are two main Timeout property in ADO.NET.

    1. Connection Timeout for Connection. It could be solved by setting ConnectionTimeout property of Connection object in Connection String.
    2. Timeout for Data access ( Command Object ). You can set
    CommandTimeout property to Command object. I recommend you set CommandTimeOut property to bigger one value. Try this. Please let me know whether this can handle this problem or not. If you have any further questions, please feel free to let me know.

     

     

    Thanks for your questions.

     

     
    Monday, August 13, 2007 8:09 AM
    Moderator
  •  

    Hi Riquel,

    Do we need to pay any performance cost when we use 'CommandTimeout'. Please give a brief about pros and cons of using CommandTimeout property.

     

    Monday, August 13, 2007 11:04 AM
  • Hi Alok,

     

    My suggestion is when it comes time to call a long query, just set the CommandTimeOut to bigger value before the query. This will avoid Timeout errors.

     

    Second I think this will not raise performance cost. CommandTimeout property is the wait time before terminating the attempt to execute a command and generating an error. This property is the cumulative time-out for all network reads during command execution or processing of the results. It does not include user processing time, only network read time. It doesn’t set the actual execution time of your command.  

     

    Hope this helps.

     

    Tuesday, August 14, 2007 2:50 AM
    Moderator
  • Hi,

    How to set "CommandTimeout" when we are using Database Application Block. Is it possible.Even i am getting the same problem, when i am calling some function. I am using application block. But i have set connection timeout to 2000 in connection string. But even i am facing same problem. But i didn't know how to set "CommandTimeout" when we are using Application Block. Please help me this. This is urgent issue i am facing.

     

    Regards,

    Sreeram

    Thursday, August 16, 2007 3:27 PM
  • Hi,

     

    This is Sreeram. This my continuation to my previous mail. i am calling procedures like this "SqlHelper.ExecuteReader".In this case how to set "commandtimeout" value for without geting timeout error. Please help me.

     

     

     

    Regards,

    Sreeram

    Thursday, August 16, 2007 3:33 PM
  •  

    when I set the commandtimeout to a upper value like 1000s it works just fine and the timeout exception disappear.

     

    thanks

    Monday, October 15, 2007 10:24 PM
  • Thanks a lot Zeeshan. Your post really helped me in my project. I was getting the same kinda Timeout error occasionally in the installer of my proj. I have not set the CommandTimeout property for the SqlCommand object. It is 30s by default. The stored proc. causing the problem was taking about 25-35s to execute. So it was throwing the timeout exception sometimes. After reading your post I have set it to 100s. It has solved the problem. I am really thankful to you. Do keep posting.

    Saturday, October 20, 2007 5:18 AM
  • I love how everyone wants to increase the timeout... completely ignoring the fact that the timeout is occurring because there's a sub-par performance issue.  Get a new engine, get better gas....

     

    If you really want to help yourself, look at the insert query and find the table that's causing the delay.  Prune the data if you have to, because despite the common overlooked but known misconception, MS-SQL cannot handle huge amounts of data.

     

    Change your timeout if you dare, but know that it's temporary and it's passing the buck (to the next developer).  Set it to Zero already... lol

    Friday, January 18, 2008 7:37 AM
  • I'm also using a huge view in the SQL Management Studio and I got the same error. But I don't know where to adjust the Timeout parameter?

    "Timeout expired. the timeout period elapsed prior to completion of the operation or the server is not responding."

    This occurs not every time but quite often...

    Thanks for your help!

    • Proposed as answer by Roger Moore Tuesday, August 18, 2009 3:25 PM
    Monday, February 04, 2008 2:23 PM
  • The MSDN article says the default timeout is 30 seconds. I am hosting 3 internal websites within my company. Default.aspx has 2 queries that read the database. Website A is constantly getting this timeout exception every 14 hours. Website A accesses a database that has a table of 860897 rows, while the other 2 websites access table of 2485 rows. I ran the query manually in SQL server management studio and it took 6 seconds. I thought it would take more than 30 seconds. There are 10 clients accessing the website and the website refreshes every 120 seconds. In a scenario like this, would it make timeout exception happen quite frequently? The timeout exception happened on the 10 clients within 14 hours.

    Thursday, April 17, 2008 3:16 PM
  • Diana, you have to choose the Query->Query Options for Microsoft SQL Server Management Studio.  The General listview item allows you to modify the timeout.
    Tuesday, August 18, 2009 3:27 PM
  • sir am venkatesh........ can u give full details for how to set connection time out propertyof Connection object in Connection String.
    • Proposed as answer by venky11421 Sunday, August 23, 2009 4:52 PM
    Sunday, August 23, 2009 4:51 PM
  • Hi, venky!
    you used VB.net , C# or C++?

     VB.Net

    Dim cmd As SqlCommand
    instance.CommandTimeout = 300

    --------
    C#

    public override int CommandTimeout { get; set; }

    -------

    C++

    public:
    virtual property int CommandTimeout {
        int get () override;
        void set (int value) override;
    }

    Monday, September 28, 2009 5:49 AM
  • Hello everyone!

    I work in the field of the WEB applications development. My issue deals with the speeding up of the interaction among the inside components of the project. Not such long time ago they suggested to me an interesting project dealing with employment of the people worldwide. The project consists of two main components, namely a WEB part and DATABASE. The set task is to speed up the functioning of the website
    www.jobofmine.com as the constant growth of users and the data they use affect both the productivity of the server and the project in general. At the moment the project is realized on the basis of the bond of the free program platform PHP+Zend+PostgreSQL.

    Will you be so kind to recommend whether it is worth using some other web-technologies to decrease the load of the server and if yes, which ones? Or will we still have to start the inner optimization of the components which we are reluctant to do as it’s always harder to remake something than to start from scratch?

    Thursday, October 15, 2009 8:36 AM
  • Hi everyone,

    I have set the CommandTimeout value to 600(10 mins) yet i am getting the problem.
    Any idea if i can use nolock with the select statement in my stored proc to fix this problem??
    Wednesday, December 16, 2009 7:39 AM
  • PS: This is randomly occuring issue. The same SP executes fine normally but sometimes i get the Timeout Expired message.
    Wednesday, December 16, 2009 7:49 AM
  • hello , sreeram1,

    it's a property of command time out object which u can set as follows :

    cmd.commandTimeout=1000;

    May this one can help u ..... 

    Saturday, February 12, 2011 10:50 AM
  • I had this same issue but the stored procedure worked fine when running it from SSMS.  The command timeout only prolongs the timeout error because the procedure runs in < 1 second. 

    To fix my issue, I had to SET QUOTED_IDENTIFIER ON for the procedure and then the aspx page worked fine.

    Thanks,
    Greg

    • Proposed as answer by SeemaChaudhary Thursday, April 21, 2011 10:59 AM
    Monday, April 04, 2011 3:16 PM
  • Dear Greg,

     SET QUOTED_IDENTIFIER ON worked for me also. Could you please tell me how does this command effects the performance of the stored procedure ??

    Thanks, Seema

    Thursday, April 21, 2011 10:11 AM
  • I'm getting this error. I have the timeout set to 30 minutes. Changed the MultipleActiveResultSets=False based on another post.

     

    It doesn't always fail but I don't think it's timeout. Could it be a DNS issue that causes the DB to not be found sometimes? Does anyone get this error locally?

     

    "The timeout period elapsed prior to completion of the operation or the server is not responding."


    - Adam J. Mendoza
    Friday, May 27, 2011 5:12 PM
  • Thanks a lot it solved my problem by setting the CommandTimeout property to big value
    Friday, June 10, 2011 1:47 PM
  • hi Greg,

    Glad Greeting

    can u please explain how this Timeout exception issuse arrrives and it get solved by SET QUOTED_IDENTIFIER ON for the procedure

    because we done stored procedure performing 2 insert and one update operation we getting the Timeout when update operation occurs

    the structure of stored procedure we used is

    1. Insert operation

    2. Update Operation

    3. Insert Operation

    i used try catch block also

    Thanks

    Nandhu

    Thursday, June 23, 2011 7:06 AM
  • In case you are using Sqlhelper.executereader, Please go to the SQLHelper Class. On the SQLHelper constructer, add one line of code sqlCmd.CommandtimeOut=500; Here's the example. public SQLHelper() { string strConn = "Data Source=abcd;Initial Catalog=myDB;user id=myID;password=myPWD"; sqlConn = new SqlConnection(strConn); sqlConn.Open(); sqlCmd = new SqlCommand(); sqlCmd.Connection = sqlConn; sqlCmd.CommandTimeout = 500; sqlDa = new SqlDataAdapter(sqlCmd); }
    Wednesday, July 27, 2011 9:32 AM