Search code examples
excelvbscriptmsxml

Vb script getting timeout error


Some background 1st solution: I have built an excel solution which imports the needed data using a from text data source. I had chosen this method as the URL which send the data will be sending a csv file. Once the data is received many process and conditions have to be applied on this.

Cause of concern: This takes a lot of time to get the data more than 6 mins. Which causes the excel to hang.

In my 2nd similar solution :- i had chosen to call a vb script from excel to do the downloading of data. This works very well for this solution. Now, i want to implement this method for 1st solution.

My main issue: The vb script used in the 2nd solution fails with the below error.

Error:- C:\Users-user id-\Desktop\script\download_moni.vbs(15, 1) msxml6.dll: The operation timed out

My code for VB Script:-

Set args = WScript.Arguments
Url = "url given here"
dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP.6.0")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", Url, False 'Open socket to get the website
xHttp.Send 'send request
with bStrm
.type = 1 '//binary
.open
.write xHttp.responseBody
.savetofile "C:\Ticket\Monitoring.csv", 2 '//overwrite
end with
wscript.echo("Download complete")

Please let me know how to fix the timeout error.


Solution

  • You say that "[it] takes a lot of time to get the data more than 6 mins." Yet the default timeout of the library you are using seems to be 30 seconds for receiving data (source).

    I am not familiar with the MSXML2.ServerXMLHTTP library you are using, but Google reveals that there is a setTimeouts method, which can be used to increase various timeouts of your library.