ClassicASP: XMLHTTP and ServerXMLHTTP

From time to time i get some memory dumps related to classic ASP. Last month I got some and the symptom was slow performance or event total hang with all requests just sitting around.

Typically when i´m looking at a classic ASP memory dump I like to use the extension that comes with DebugDiag called IISInfo.dll that helps me getting a nice view on requests executing. Below are the commands available with this extension (I won´t get into details but they are pretty much self explanatory).

 

IISInfo.dll - DebugDiag/WinDBG hybrid extension for IIS and ASP information.

-----------------------------------------------------------------------------------------------

Usage:

!clientconns - Active client connections

!asprequests - ASP request information about all executing ASP requests

!asprequest [<CHitObj>] - ASP request information executing on current thread or specified optional CHitObj address

!templates - All cached templates

!aspstack - Script call stack for the ASP page running on the current thread

!asppages - ASP page running on all threads

!asptemplate <CTemplate> - Detailed information and include heirarchy for the specified template

!templatecode <CTemplate> - Compiled template code or expanded code for the specified template

!includecode <FileMapKey> - Compiled template code or expanded code for the specified include file

!aspapps - Loaded ASP applications

!aspapp <CAppln> - Detailed information for the specified ASP application

!appvars <CAppln> - Variables stored in the specified ASP Application collection

!sessions <CAppln> - Active sessions in the specified ASP application

!session <CSession> - Detailed information about the specified ASP session

!sessvars <CSession> - Variables stored in the specified ASP Session collection

!help - Shows this help

 

In this specific case, after looking at requests executing all were getting struck on Xmlhttp send

 

Function Scope Line Of Code

----------------------------------------------------------------------------------------

GetRequest oXmlhttpServer.send [PATH @ 123]

Global Scope GetRequest(parameters)

And call stack showed something like this

NTDLL!NtWaitForSingleObject+0xb

KERNEL32!WaitForSingleObjectEx+0x71

KERNEL32!WaitForSingleObject+0xf

WININET!URL_CONTAINER::LockContainer+0x23

WININET!URL_CONTAINER::GetHeaderData+0x10

WININET!GetCurrentSettingsVersion+0x29

WININET!InternetSettingsChanged+0x10

WININET!InternetConnectA+0x93

URLMON!CINet::INetAsyncConnect+0x135

URLMON!CINet::INetAsyncOpen+0xde

URLMON!CINet::INetAsyncStart+0x15

URLMON!CINet::Start+0x1d9

URLMON!COInetProt::Start+0x62

URLMON!CTransaction::Start+0x3ac

msxml4!URLMONRequest::send+0xc9

msxml4!XMLHttp::send+0x3a

msxml4!XMLHttp::_invoke+0xf2

msxml4!_dispatchImpl::InvokeHelper+0x10b

msxml4!_dispatchImpl::Invoke+0x3d

msxml4!__dispatch::Invoke+0x2b

The source code was showing that a XMLHTTP object was being created and then a request was made. So what was the problem about creating a XMLHTTP object ? Well, sending XMLHTTP requests from server is not supported and can lead to poor performance or even worse. Our solution was to use the SERVERXMLHTTP.

Below are some links of interest around XMLHTTP vs SERVERXMLHTTP.

“Active Server Pages (ASP) script or Internet Server API (ISAPI) code that attempts to use XMLHttpRequest (Microsoft.XMLHTTP) functionality of the Microsoft XML engine (MSXML) to send XML requests to another Web server may function incorrectly or perform poorly.”

https://support.microsoft.com/kb/237906/en-us  (PRB: Loading Remote XML or Sending XML HTTP Requests from Server Is Not Supported)

 “Using ServerXMLHTTP or WinHTTP objects to make recursive Hypertext Transfer Protocol (HTTP) requests to the same Internet Information Server (IIS) server is not recommended. More specifically, the calling Active Server Page (ASP) should not send requests to an ASP in the same virtual directory or to another virtual directory in the same pool or process. This can result in poor performance due to thread starvation.”

https://support.microsoft.com/default.aspx?scid=kb;EN-US;316451 (INFO: Do Not Send ServerXMLHTTP or WinHTTP Requests to the Same Server)

 

XMLHTTP and ServerXMLHTTP?

As the name suggests, ServerXMLHTTP is recommended for server applications and XMLHTTP is recommended for client applications. XMLHTTP has some advantages such as caching and auto-discovery of proxy settings support. It can be used on Windows 95 and Windows 98 platforms, and it is well-suited for single-user desktop applications.”

https://support.microsoft.com/kb/290761 (Frequently asked questions about ServerXMLHTTP)

Have fun!!!

Bruno