Todo sobre Timeout en ASP - Visual Basic

How do I increase timeout values?

For most timeout situations, my first suggestion would be to improve the code's efficiency so that it does't time out at all. I realize, however, that some timeout issues are beyond the developer's control (e.g. waiting for a response from a remote server). Also, there are many scenarios where you would want to increase the session timeout so that users can "stay" longer.

Server.ScriptTimeout

This value indicates how long, in seconds, the server will let an ASP script run until it is stopped by the server. The default value is 90 seconds. An error occurs if a script requires more time than this value allows (see Article #2366), but you can override the default. To change this value in an individual ASP page, you can add this code:

<%
Server.ScriptTimeout = 180
%>

To change this value for an entire application, open Internet Services Manager, go to the Home Directory tab of the application, click on configuration, and alter the ASP Script timeout field on the "App Options" tab. If you do not have access to the web server directly, you can also use ADSI to change this value on a per-application basis. Keep in mind that with this method you can only override the default with a value GREATER than that stored in the metabase - if you try to lower the current value, the change will not take effect.

The minimum value for ScriptTimeout is 0 (which means never time out). If you try to set it to a negative number (-1 is a common pitfall; it is often associated with "infinite"), you will get the following:

error '80004005'
Unspecified error

The maximum value for ScriptTimeout is 2^32-1, or 2147483647. If you try to set it to 2147483648 or higher, you will get the following error:

Microsoft VBScript runtime (0x800A0006)
Overflow: 'server.scripttimeout'

If you need this much time, you need to investigate your script, because it must be horribly inefficient. And no user (or even browser) will ever wait that long for a page to render.

Session.Timeout

This setting controls how long, in minutes, a user's session will last. While it is wise to keep this value short for efficiency's sake, there are cases where that's just not enough time for users to get things done in your application (for example, if you have a client-side tool where the user is changing properties but not making requests to the server until they are done). The default is 20 minutes, and once 20 minutes of inactivity has occured, the session expires and all session variables are lost. You can increase the session timeout in an ASP page or in global.asa's Session_onStart() method with the following code:

<%
Session.Timeout = 45
%>

To change this value for an entire application, open Internet Services Manager, go to the Home Directory tab of the application, click on configuration, and alter the Session timeout field on the "App Options" tab. This metabase setting is also exposed to ADSI.

conn.connectionTimeout

Where conn is an ADODB.Connection object that is not yet open, the connectionTimeout property will indicate the amount of time, in seconds, to wait for an ASP application to initially connect to the data source. The default is 15 seconds; to override the default, use syntax as follows:

<%
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionTimeout = 120
conn.Open
%>

commandTimeout

CommandTimeout tells the server how long to wait, in seconds, for completion of any command sent to the data source. This value is editable before and after the connection has been opened. The default is 30 seconds, but you can override it like this:

<%
Set conn = CreateObject("ADODB.Connection")
conn.Open
conn.CommandTimeout = 120
%>

Note that you can also apply a commandTimeout value to a command object, and it will behave independent of the commandTimeout value associated with the connection object. So for specific stored procedures or other commands being executed explicitly through the ADODB.Command object, you could have a longer timeout than that of the connection object. The syntax for the command object is almost identical:

<%
Set cmd = CreateObject("ADODB.Command")
cmd.CommandTimeout = 120
%>

Note that Oracle drivers do not support the commandTimeout property, up to and including MDAC 2.7. See KB #251248 for more information.

XMLHTTP timeouts

Adalberto Montanía
Fuente: http://classicasp.aspfaq.com/general/how-do-i-increase-timeout-values.html

For information on increasing or decreasing the time allowed for the ServerXMLHTTP object to retrieve a response from a remote server, see Article #2407.

Comentarios