Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IntGetFile timeout question..
#1
Hi -

I'm trying to diagnose an issue with QM when IntGetFile times out (the timeouts are caused by a server side issue - the server is not responding to requests due do a completely separate issue). The error is handled OK within the thread. But - does anything else in QM (other web service calls, other threads) get blocked if IntGetFile is waiting for a response?

In our application we have a number of different threads (probably between 4 and 8 depending on what's going on). I know that in browsers that they have a small number of connections (IE 9 is on most of the machines - this permits 6 connections while IE 7 only permits 2 - but I don't know what the limit would be in QM).

The issue might be entirely different from this (maybe just bad error handling on my part) but if there are limits in the number of connections that can go through HttpOpenRequest it might help narrow my search. Thanks.

Sean
#2
QM internet functions use a group of Windows API functions called "WinInet". QM function IntGetFile uses WinInet functions InternetOpenUrl, InternetQueryDataAvailable, InternetReadFile.

Here is what I found about the max number of connections:
http://support.microsoft.com/KB/183110

Internet Explorer also uses these functions, or just these registry settings. Possibly depends on IE version.
#3
Try this function that uses WinHTTP API.

Function IntGetFileWH
Code:
Copy      Help
;/
function# $url str&s [str&responseHeaders]

;Downloads web page or other file from the Internet.
;Returns HTTP status code (200 is OK).
;Error if failed.

;url - file to download. Example: "http://www.x.com/index.htm"
;s - variable that receives file data.
;responseHeaders - variable that receives raw response headers.

;REMARKS
;There are 2 ways specify proxy settings:
;;;1. Call <help>IntSettings</help> with useproxy = 1 and proxy_name etc. The this function will call <link "https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059%28v=vs.85%29.aspx">WinHttpRequest.SetProxy</link> with these settings.
;;;2. Run WinHTTP proxy configuration utility <link "https://msdn.microsoft.com/en-us/library/windows/desktop/aa384069%28v=vs.85%29.aspx">Netsh.exe or ProxyCfg.exe</link>. These proxy settings are used by this function and WinHTTP functions, and are not those used by Internet Explorer and WinInet functions that are used by IntGetFile and other QM functions.
;To not use a proxy, call IntSettings with useproxy = 2, or don't configure proxy settings with the configuration utilities.

;EXAMPLE
;str s
;int status=IntGetFileWH("http://www.quickmacros.com/index.html" s)
;if(status!=200) end F"failed, status={status}"
;out s


opt noerrorshere 1
typelib WinHttp {662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1

WinHttp.WinHttpRequest r._create

;apply IntSettings
sel __intsett.useproxy
,case 1 r.SetProxy(2 __intsett.proxy_name __intsett.proxy_bypass)
,case 2 r.SetProxy(1)

r.Open("GET" url)
r.SetRequestHeader("User-Agent" iif(__intsett.user_agent.len __intsett.user_agent "Quick Macros"))
r.Send
;r.WaitForResponse
if(&responseHeaders) responseHeaders=r.GetAllResponseHeaders
ARRAY(byte) a=r.ResponseBody
s.fromn(&a[0] a.len)
ret r.Status

WinHTTP by default does not limit the number of connections per server. There is such option, and its default value is infinite.
#4
Hi Gintaras,

My questions are as below, do you have any ideas? My QM is connect " http://dir.twseo.org/ip-check.php" to get html information and check IP. Thanks you in advance.
1.The function " IntGetFileWH " seems that it can't work with proxy setting of function "IntSettings",

2. I try to use free proxy to test IntGetFile and get the proxy ip not my real ip, it can work, but if I use one of the free proxy list and some Proxy IPs will get " failed A connection with the server could not be established" in QM, then the QM will stop in IntGetFile, the code will can't run again. (In my codes, I change the proxy ip every time and repeat.

3. I use function "IntGetFile" to get html information, and it always success in a few seconds, but sometimes it can't get html information immediately and fail finally. But I can connect to the same URL in Chrome at the same time. I restart the QM and it maybe not work, but I restart my computer and it can work.

4. I try to use "Http" to "Connect" URL and "Get" html information, and it can work, and my codes change the proxy ip every time and repeat, but I always get the same Proxy Ip, but the "IntGetFile" code will get different proxy IPs.
#5
I updated IntGetFileWH, now it should support proxy. Not tested.

4. Maybe need to change proxy earlier. But it will have the same problems as IntGetFile.
#6
Hi Gintaras,
Thank for your advice.
I use the new Function IntGetFileWH, but error as below.

Macro Macro12
Code:
Copy      Help
IntSettings(1 "http=http://210.101.131.232:8080")
str html
int status=IntGetFileWH("http://dir.twseo.org/ip-check.php" html)

0x80072F44,
This method cannot be called until the Open method has been called.
#7
Hi Gintaras,
Thank for your advice.
I use the new Function IntGetFileWH, but error as below.

Macro Macro12
Code:
Copy      Help
IntSettings(1 "http=http://210.101.131.232:8080")
str html
int status=IntGetFileWH("http://dir.twseo.org/ip-check.php" html)

0x80072F44,
This method cannot be called until the Open method has been called.
#8
Now fixed.
#9
Hi Gintaras,
It can work, thanks.


Forum Jump:


Users browsing this thread: 1 Guest(s)