Handling Script Timeout when invoking ActiveX Object

P

Patrick

I understand that with IIS5.1 on Windows XP Professional SP1, I can
1) Either set under IIS Manager-> Any specific Virtual Directory->
Configuration->Options->ASP Script timeout for all pages within that
directory OR
2) Within a specific page, set the timeout as per
http://www.microsoft.com/windows200...indows2000/en/server/iis/htm/asp/vbob246s.htm
e.g. <% Server.ScriptTimeout = 1 %>

and that the value in 2 cannot be less than that of 1


What I am doing from an ASP page is as follows:

Dim objOrderClient
objOrderClient = CreateObject("Order.Client")

objOrderClient.PlaceOrder(objOrder)


The problem is that objOrderClient.PlaceOrder can potentially "time-out".
What I want is for the ASP Script to give the ActiveX Object (a .NET Class
library which I invoke via .NET/COM Interop) up to 30 seconds to run, and if
the ActiveX Object does not "return" within 30 seconds, then handle the
timeout according (e.g. redirect to an error page or to display a custom
error message). Checking err.description does *not* work:

On error resume next
' Some more code
Dim objOrderClient
objOrderClient = CreateObject("Order.Client")

objOrderClient.PlaceOrder(objOrder)

If err.number<>0 then
%>
SOS SOS <br>
<%=err.Description%>
<%
end if

Because, obviously the script is timing out at the point when PlaceOrder is
executing!

What I get is the following standard Microsoft error, which is rather
unprofessional for a production website!

Script timed out

/Publications/testiorder.asp

The maximum amount of time for a script to execute was exceeded. You can
change this limit by specifying a new value for the property
Server.ScriptTimeout or by changing the value in the IIS administration
tools.
 
P

Patrick

Thanks, but this MSDN article only *partially* solve the problem!

Yes, when the script timed-out in the infinite loop as in the example code
from the article, the OnTransactionAbort EventHandler get fired to print out
the desired output. Unfortunately, before the output from the EventHandler
is displayed, the standard Microsoft error has already displayed, as
follows, how could I prevent this standard Microsoft error from being
displayed!!
Active Server Pages error 'ASP 0113'

Script timed out

/timeout.asp

The maximum amount of time for a script to execute was exceeded. You can
change this limit by specifying a new value for the property
Server.ScriptTimeout or by changing the value in the IIS administration
tools.
 
P

Patrick

Also, I can only get the example working with the "Mickey mouse" MSDN
Example.

In a proper scenario, I have an ASP Page, which
1) server.createobject("adodb.connection") an ADODB.connection
2) invokes. execute(mySQL) on the ADODB.connection to get a Record Set
3) Does a CreateObject on a .NET Class Library via Interop (using the regasm
/tlb tool)
4) Invoke a method on the ActiveX object of 3

Problems
1) When the page is set to either of the following
<%@ TRANSACTION=REQUIRES_NEW LANGUAGE="VBScript" %>
<%@ TRANSACTION=REQUIRED LANGUAGE="VBScript" %>

2) I get error
err.number= -2147168246
err.Description= New transaction cannot enlist in the specified transaction
coordinator.
( After the page loads, resulting in the above error, the COM+ Committed
Transaction statistics increments by 1, this is on IIS5.1 on WinXP
Professional SP1)

3) The page runs without error (with the exception when the page timeout, of
course) when
3.1) The page has no transaction attributes set or
3.2) Transaction attribute is set to SUPPORTED or NOT_SUPPORTED

4) With this production ASP page, the OnTransactionAbort sub-routine is not
fired off even when the page times-out!

SOS
 
P

Patrick

I have figured out that
1) It is NOT the CreateObject or call to the .NET Interop class library that
is causing this problem
2) It seems to be the ADODB that is causing the problem!
2.1) The SQL Server against which SQL are executed are on a SQLServer 2000
SP3a on a remote server within the same network running Windows Server 2003
2.2) The following are executed:
set connTemp = createobject("adodb.connection")
connTemp.Open connString
set openRSexecute = conntemp.execute(updateSQL)
if err.number <> 0 then
%><%=err.Desription%><%
end if
 
P

Patrick

OK, but I still have problem with using the "Transaction" page attribute,
from a page that use ADODB to issue SQL Update statement against a remote
SQL Server within the same network

I can only get the example working with the "Mickey mouse" MSDN Example at
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q182036

In a proper scenario, I have an ASP Page, which
1) server.createobject("adodb.connection") an ADODB.connection
2) invokes. execute(mySQL) on the ADODB.connection to get a Record Set
3) Does a CreateObject on a .NET Class Library via Interop (using the regasm
/tlb tool)
4) Invoke a method on the ActiveX object of 3

Problems
1) When the page is set to either of the following
<%@ TRANSACTION=REQUIRES_NEW LANGUAGE="VBScript" %>
<%@ TRANSACTION=REQUIRED LANGUAGE="VBScript" %>

2) I get error
err.number= -2147168246
err.Description= New transaction cannot enlist in the specified transaction
coordinator.
( After the page loads, resulting in the above error, the COM+ Committed
Transaction statistics increments by 1, this is on IIS5.1 on WinXP
Professional SP1)

3) The page runs without error (with the exception when the page timeout, of
course) when
3.1) The page has no transaction attributes set or
3.2) Transaction attribute is set to SUPPORTED or NOT_SUPPORTED

4) With this production ASP page, the OnTransactionAbort sub-routine is not
fired off even when the page times-out!

I have figured out that
1) It is NOT the CreateObject or call to the .NET Interop class library that
is causing this problem
2) It seems to be the ADODB that is causing the problem!
2.1) The SQL Server against which SQL are executed are on a SQLServer 2000
SP3a on a remote server within the same network running Windows Server 2003
2.2) The following are executed:
set connTemp = createobject("adodb.connection")
connTemp.Open connString
set openRSexecute = conntemp.execute(updateSQL)
if err.number <> 0 then
%><%=err.Desription%><%
end if
 
P

Patrick

More findings.
1) With the ASP file listed at the end of this post, If
1.1) I load the ASP on Server A, where Server A
1.1.1) contains the target DB as stated in connection string
1.1.2) running IIS6.0 on a Windows 2003 Server
1.1.3) Running SQL Server 2000 SP3a
Then, The ASP run successfully displaying "db openend" and "record updated"
1.2) If I load the ASP on a Windows XP Professional SP1 machine B
1.2.1) with the ASP containign the same target DB as stated in connection
string
1.2.1) Running windows XP Pro SP1, IIS5.1 on the same domain as the Windows
2003 server A
Then I get the following error:
ERROR-2147168246
New transaction cannot enlist in the specified transaction coordinator.

I have played around with the following (following the articles/newsgroup
posting you suggested)
1) MSDTC is definitely started
2) Machine pings OK
3) SQL Client is set to use TCP/IP only with Enabled shared memory unticked
4) Transaction timeout set to 80 seconds (although the error is returned
straight away!)
5) On Component services:
5.1) Default Properties Tab:
5.1.1) Ticked Enabled DCOM on this computer
5.1.2) Ticked enable COM Internet Services on this computer
5.1.2) Default Authentication level set to: Connect
5.1.3) Default Impersonation tried: Tried all 4 settings ( all results in
same error)
5.2) DCOM Security Tab
5.2.1) Ensure IWAM_MachineName and IUSR_MachineName has launch premission
5.3) MSDTC Tab
5.3.1) Ticked Network DTC Access, Network Administration, Network
Transacitons and XA Transaction
5.3.2) DTC Logon Account:
5.3.2.1) Set to LocalSystem
5.3.2.1) If I try to set to a Domain account that belongs to the Admin group
on both the WinXP Pro and windows 2003 server server, I get the following
logged:
Event Type: Error
Event Source: MSDTC Client
Event Category: MSDTC User Interface
Event ID: 4429
Date: 15/11/2004
Time: 09:37:56
User: N/A
Computer: WindXPPro
Description:
Failed to set the security attributes on the MS DTC service. Internal
Information : Pid = 2184, File:
d:\nt_qxp\com\com1x\dtc\dtc\dacdll\src\transcfgdlg.cpp, Line: 461,
ApplyAccountSettings failed, hr=0x8007007b

..

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 7b 00 07 80 {..€

6) Note the MSDTC Trace files at %SYSTEMROOT%\system32\MsDtc\Trace are
pretty binary and meaningless to me!

7) Note I only get a problem with the ASP file if Transaction attribute is
set to Required or ReqruiesNews!

-----------------------------Start of
dbTimeout.asp-----------------------------
<%@ TRANSACTION=Required LANGUAGE="VBScript" %>
<%Response.Buffer = TRUE%>
<HTML>
<HEAD>
<TITLE>Simple Transactional Web Page</TITLE>
</HEAD>
<BODY BGCOLOR="White" topmargin="10" leftmargin="10">
<font size="4" face="Arial, Helvetica">
<b>Transactional Web Page</b></font><br>
<hr size="1" color="#000000">
<p>
This is an example of an Aborted Transaction.
This transaction will abort due to a Script
Time-out error, which is an error that you
could not trap without a transaction.
</p>
<p>
Please wait until the script times out...
</p>

<%

if UCase(dbLocked) = "Y" then
'call errorDB("<b>" & langErrStoreClosed & "</b>","")
%>database locked<%
end if
on error resume next
set connTemp = server.createobject("adodb.connection")
connTemp.Open connString
if err.number <> 0 then

%><h1>ERROR<%=err.Number%><br><%=err.Description %></h1><%
Response.End
end if
%><b>DB Opened</b><br><%

mySQL = "UPDATE cartHead SET zip = 'E' WHERE idCust=91414"
set rsTemp = conntemp.execute(mySQL)
if err.number <> 0 then
%><h1>ERROR<%=err.Number%><br><%=err.Description %></h1><%
Response.End
end if
call closeRS(rsTemp)

%><b>record updated</b><%
closeDB()
'Do while 1 = 1
'Infinite Loop
'Loop
%>
</BODY>
</HTML>
<%
' The Transacted Script Abort Handler. This sub-routine
' will be called if the script transacted aborts

Sub OnTransactionAbort()
Response.Write "&lt;p&gt;&lt;b&gt;The Transaction just aborted&lt;/b&gt;."
Response.Write "This message came from the "
Response.Write "OnTransactionAbort() event handler."
end sub


'*************************************************************************
'Declare some standard ADO variables
'*************************************************************************
Const adOpenKeyset = 1
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adLockOptimistic = 3
Const adStateClosed = &H00000000
Const adUseServer = 2
Const adUseClient = 3
Const adCmdText = &H0001
Const adCmdTable = &H0002
const connString = "Provider=SQLOLEDB.1;Password=publications;Persist
Security Info=True;User ID=publications;Initial Catalog=Publications;Data
Source=dev"

%>

-----------------------------End of
dbTimeout.asp-----------------------------
 
S

Steven Cheng[MSFT]

Hi Patrick,

As you mentioned that the COM error will occur when you run the page with
Transaction attribute set as following
<%@ TRANSACTION=REQUIRES_NEW LANGUAGE="VBScript" %>
<%@ TRANSACTION=REQUIRED LANGUAGE="VBScript" %>

Also, since you are calling the managed interoped assembly in that page,
will the problem also go away if there is only unmanaged code in it(no
interop code)?

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
P

Patrick

1) The problem is completely unrelated to Interop. As I mentioned before,
the problem occur with even the following enclosed snipped ASP page.

2) The problem *at the point of Opening a connection to the SQL Server on a
*Remote* SQL Server 2000 SP3a database on a Window 2003 Server.

3) No .NET interop class libraries, etc. are invoked from this dbTimeout.asp
(although in reality I will do).

4) The fact that the dbTimeout.asp loads OK when loaded from IIS6.0 on the
Windows 2003 server on which the target SQL Server database is also hosted,
but I get error when loaded from IIS5.1 on a remote WinXP Pro SP1
workstation that is within the same Domain and network subnet (no VPN, etc.)

5) As indicated in my post of 15Nov04 11:42 (GMT), I have also experimented
with various MSDTC settings) but no joy !

6) Problem only occur when Transactional attribute of ASP page is set to
REQUIRED or REQUIRES_NEW. the reason I am doing this because I am trying to
"trap" and handle ASP page time-out as per
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q182036




-----------------------------Start of
dbTimeout.asp-----------------------------
<%@ TRANSACTION=Required LANGUAGE="VBScript" %>
<%Response.Buffer = TRUE%>
<HTML>
<HEAD>
<TITLE>Simple Transactional Web Page</TITLE>
</HEAD>
<BODY BGCOLOR="White" topmargin="10" leftmargin="10">
<font size="4" face="Arial, Helvetica">
<b>Transactional Web Page</b></font><br>
<hr size="1" color="#000000">
<p>
This is an example of an Aborted Transaction.
This transaction will abort due to a Script
Time-out error, which is an error that you
could not trap without a transaction.
</p>
<p>
Please wait until the script times out...
</p>

<%

if UCase(dbLocked) = "Y" then
'call errorDB("<b>" & langErrStoreClosed & "</b>","")
%>database locked<%
end if
on error resume next
set connTemp = server.createobject("adodb.connection")
connTemp.Open connString
if err.number <> 0 then

%><h1>ERROR<%=err.Number%><br><%=err.Description %></h1><%
Response.End
end if
%><b>DB Opened</b><br><%

mySQL = "UPDATE cartHead SET zip = 'E' WHERE idCust=91414"
set rsTemp = conntemp.execute(mySQL)
if err.number <> 0 then
%><h1>ERROR<%=err.Number%><br><%=err.Description %></h1><%
Response.End
end if
call closeRS(rsTemp)

%><b>record updated</b><%
closeDB()
'Do while 1 = 1
'Infinite Loop
'Loop
%>
</BODY>
</HTML>
<%
' The Transacted Script Abort Handler. This sub-routine
' will be called if the script transacted aborts

Sub OnTransactionAbort()
Response.Write "&lt;p&gt;&lt;b&gt;The Transaction just aborted&lt;/b&gt;."
Response.Write "This message came from the "
Response.Write "OnTransactionAbort() event handler."
end sub


'*************************************************************************
'Declare some standard ADO variables
'*************************************************************************
Const adOpenKeyset = 1
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adLockOptimistic = 3
Const adStateClosed = &H00000000
Const adUseServer = 2
Const adUseClient = 3
Const adCmdText = &H0001
Const adCmdTable = &H0002
const connString = "Provider=SQLOLEDB.1;Password=publications;Persist
Security Info=True;User ID=publications;Initial Catalog=Publications;Data
Source=dev"

%>

-----------------------------End of
dbTimeout.asp-----------------------------
 
S

Steven Cheng[MSFT]

Hi Patrick,

Thanks for your followup. I've also noticed the thread of

Handling Script Timeout when invoking ActiveX Object involving ADODB from
ASP2.0 pages

in the mts.programming group. As some other member of our team has
suggested, we are more recommended that you try contacting the PSS to do
some thorough throubleshooting on this issue due to the limitation of the
newsgroup commutity.
You can contact Microsoft Product Support directly to discuss additional
support options you may have available, by contacting us at 1-(800)936-5800
or by choosing one of the options listed at
http://support.microsoft.com/default.aspx?scid=sz;en-us;top.

Thanks for your understanding.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
P

Patrick

Are you at least able to *reproduce* my problem?
i.e., loading the appended ASP file on IIS 5.1 on WinXP Pro SP2 against a
SQL Server 2000 SP3a on another Windows 2003 server within the same domain,
network subnet.

There needs to be a publications database on the dev server with a carthead
table with a varchar field called zip, as configured by the connString
variable.

-----------------------------Start of
dbTimeout.asp-----------------------------
<%@ TRANSACTION=Required LANGUAGE="VBScript" %>
<%Response.Buffer = TRUE%>
<HTML>
<HEAD>
<TITLE>Simple Transactional Web Page</TITLE>
</HEAD>
<BODY BGCOLOR="White" topmargin="10" leftmargin="10">
<font size="4" face="Arial, Helvetica">
<b>Transactional Web Page</b></font><br>
<hr size="1" color="#000000">
<p>
This is an example of an Aborted Transaction.
This transaction will abort due to a Script
Time-out error, which is an error that you
could not trap without a transaction.
</p>
<p>
Please wait until the script times out...
</p>

<%

if UCase(dbLocked) = "Y" then
'call errorDB("<b>" & langErrStoreClosed & "</b>","")
%>database locked<%
end if
on error resume next
set connTemp = server.createobject("adodb.connection")
connTemp.Open connString
if err.number <> 0 then

%><h1>ERROR<%=err.Number%><br><%=err.Description %></h1><%
Response.End
end if
%><b>DB Opened</b><br><%

mySQL = "UPDATE cartHead SET zip = 'E' WHERE idCust=91414"
set rsTemp = conntemp.execute(mySQL)
if err.number <> 0 then
%><h1>ERROR<%=err.Number%><br><%=err.Description %></h1><%
Response.End
end if
call closeRS(rsTemp)

%><b>record updated</b><%
closeDB()
'Do while 1 = 1
'Infinite Loop
'Loop
%>
</BODY>
</HTML>
<%
' The Transacted Script Abort Handler. This sub-routine
' will be called if the script transacted aborts

Sub OnTransactionAbort()
Response.Write "&lt;p&gt;&lt;b&gt;The Transaction just aborted&lt;/b&gt;."
Response.Write "This message came from the "
Response.Write "OnTransactionAbort() event handler."
end sub


'*************************************************************************
'Declare some standard ADO variables
'*************************************************************************
Const adOpenKeyset = 1
Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adLockOptimistic = 3
Const adStateClosed = &H00000000
Const adUseServer = 2
Const adUseClient = 3
Const adCmdText = &H0001
Const adCmdTable = &H0002
const connString = "Provider=SQLOLEDB.1;Password=publications;Persist
Security Info=True;User ID=publications;Initial Catalog=Publications;Data
Source=dev"

%>
-----------------------------End of
dbTimeout.asp-----------------------------


Yan-Hong Huang said:
Hello Patrick,

I reviewed the issue thread. It seems that our engineer Luke also worked
with you on this issue in another thread before.

Looking at the nature of this issue, it would require intensive
troubleshooting which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional through Microsoft Product
Support Services. You can contact Microsoft Product Support directly to
discuss additional support options you may have available, by contacting us
at 1-(800)936-5800 or by choosing one of the options listed at
http://support.microsoft.com/default.aspx?scid=fh;EN-US;OfferProPhone. If
it is a product issue, the service request is free.

Thanks very much for your understanding.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam. as
p&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
S

Steven Cheng[MSFT]

Thanks for your followup, Patrick,

If so, would you try providing a simplized version such as a simple sql db
structure which is enough to perform the transaction operations in your
test pages. Then, we can try do some local repro tests on our side. Thanks.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Y

Yan-Hong Huang[MSFT]

Hi Patrick,

I have replied you in the same thread in microsoft.public.mts.programming
group. If you have any more concerns on it, please feel free to post there.
We will follow up it in that thread.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
p&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top