views:

243

answers:

4

Hi there,

I am using vbscript .vbs in windows scheduler.

Sample code:

objWinHttp.Open "POST", http://bla.com/blabla.asp, false
objWinHttp.Send 
CallHTTP= objWinHttp.ResponseText

strRESP= CallHTTP(strURL)

WScript.Echo "after doInstallNewSite: " & strRESP

Problem: blabla.asp is handling a task that need around 1-2 minute to complete. It should return 'success' when the task completed. But it return a empty result to the server vbs. (shorter than the normal time to complete the thing. I then go to check whether the task is completed, the answer is yes too.

I found this to happen when the task need longer time to complete.

Is this the weakness of vbs? Help!!!

A: 

What is objHTTP specifically?

Looking at the target server's log, was the request received?

EricLaw -MSFT-
Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
Remou
A: 

I can't find this in server log.

objWinHTTP is a standard protocol to send call and wait for response.

I did try using PHP and curl to do the whole process, but failed. Reason: PHP is part of the component in windows server. When come to global privilege and file folder moving, it is controlled by windows server. So I give up, and use vbs.

objWinHTTP is something act like curl in PHP.

i need help
A: 

sounds to me like the request to is taking too long to complete and the server is timing out. I believe the default timeout for asp scripts is 90 seconds so you may need to adjust this value in IIS or in your script so that the server will wait longer before timing out.

From http://msdn.microsoft.com/en-us/library/ms525225.aspx:

The AspScriptTimeout property specifies (in seconds) the default length of time that ASP pages allow a script to run before terminating the script and writing an event to the Windows Event Log. ASP script can override this value by using the ScriptTimeout property of the ASP built-in Session object. The ScriptTimeout property allows your ASP application to set a higher script timeout value. For example, you can use this setting to adjust the timeout once a particular user establishes a valid session by logging in or ordering a product.

free-dom
+2  A: 

You can specify timeouts for the winhttp component:

objWinHttp.SetTimeouts 5000, 10000, 10000, 10000

It takes 4 parameters: ResolveTimeout, ConnectTimeout, SendTimeout, and ReceiveTimeout. All 4 are required and are expressed in milliseconds (1000 = 1 second). The defaults are:

  • ResolveTimeout: zero (no time out)
  • ConnectTimeout: 60,000 (one minute)
  • SendTimeout: 30,000 (30 secs.)
  • ReceiveTimeout: 30,000 (30 secs.)

So I suggest increasing the ReceiveTimeout

edosoft
thanks, no wonder I realize the return response at vbs is always around 30 over seconds. Your solution works.
i need help