[WinHTTP 5.1 Object] request reached timeout

3 posts in this topic

#1 ·  Posted (edited)

Hi everyone,

I have a script that call this function again & again normaly

Func CallAPI($amount, $target, $condition, $API_key)
    $Response = $oHTTP.ResponseText
    Return $Response

but sometime (may be after 105 request, 203 request, 1000 request, ... n request) this request error and make my script stop 


I think sever response slow that make this request reached default timeout.

I try to set time out with hope if reached timeout this request will return error or something else and my script keep run continue


HTTP Timeouts With AutoIt

To easily change the timeouts, we can simply change all of them at the same time, in one line of code.


The timeouts that you set with the above line of code are as follows:

ResolveTimeout Maximum time allowed to use when resolving a host name, such as brugbart.com, to an ip address.
ConnectTimeout Maximum time allowed to spend when connecting to a server, if a server does not respond within this time, the connection is dropped.
SendTimeout Timeout for individual packets. Larger packets are normally broken up into multiple smaller packets.
ReceiveTimeout Timeout for incoming packets. Again, larger packets are normally broken into multiple smaller ones.

but it when request reached timeout, my script error, exit and return the same message above.

Anyone have any idea too fix this disadvantage, or when sever response slow it will skip this request and return error code and countinue code without exit?

Thanks everyone T.T

Edited by nhocquan

Share this post

Link to post
Share on other sites

The example from the AutoIt documentation  (ObjEvent) shows how to:

44 minutes ago, nhocquan said:

return error code and countinue code without exit


1 person likes this

Share this post

Link to post
Share on other sites

#3 ·  Posted (edited)

6 hours ago, genius257 said:

The example from the AutoIt documentation  (ObjEvent) shows how to:


Thank you very much :*

Edited by nhocquan

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • jandings
      WinHTTP Get (to a REST API): Authentication problem
      By jandings
      Hello there,
      I'm trying to query a REST API of a webservice, SHOPWARE to be precise. The API is very well documented (https://developers.shopware.com/developers-guide/rest-api/#using-the-rest-api-in-your-own-a) but only using PHP. I tried some stuff but could not make it work.
      It should be very simple, because the following simply works in a Chrome-Browser:
      queries me for username and passphrase and then dumps order number 300.
      Now I try to do the same in AutoIt (based on the wonderful work of many contributors here):
      #include-once #include "..\INCLUDE\winhttp.au3" #include "..\INCLUDE\OO_JSON.au3" ;Proxy Config Global $oJSON = _OO_JSON_Init() Global $obj = "" Global $sUserName = "USERNAME" Global $sPassword = "PASSPHRASE" Global $sDomain = "www.SHOPWAREDOMAIN.com/api/orders/300" Global $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) JOC/0.1") ; without ie proxy settings $hConnect = _WinHttpConnect($hOpen, "https://" & $sDomain) ConsoleWrite ($hConnect & "#") $sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sUserName & ":" & $sPassword & "@" & $sDomain, Default ) ;$sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sDomain, Default, $sUserName & ":" & $sPassword) ;$sReturned = _WinHttpSimpleSSLRequest($hConnect, "GET", $sDomain, Default, , $sUserName & ":" & $sPassword ) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned ConsoleWrite ($sReturned & "#" & @error) Whatever version I use (I tried the commented ones and many others), I always get a reply from Shopware:
      {"success":false,"message":"Invalid or missing auth"}
      At least this comes from Shopware. But there must be some format of the credentials that I don't know or understand.
      Any help?
    • AutID
      WinHTTPSimpleRequest keep connection alive
      By AutID
      sry my fault. Got this working. It was just a typo mistake. Please delete thread
    • ruslanas402
      WinHTTP & post multi FB image
      By ruslanas402
      Hello there, could anyone advanced in WinHTTP tell me what am I missing please?
      #include "WinHttp.au3" #include <Array.au3> $sPic = "C:\Users\Source\Pictures\Capturex1.PNG" $sPic2 = "C:\Users\Source\Pictures\Capturex2.PNG" $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, "https://m.facebook.com/") $sRead = _WinHttpSimpleFormFill($hConnect, "login.php", "login_form", "name:email", "login@mail.com", "name:pass", "pasword") $aRead = _WinHttpSimpleFormFill($hConnect, "/groups/1111111111111", "index:1", "name:view_photo", True, "[RETURN_ARRAY]") ;<-- 11111... <-- Group ID $aURL = _WinHttpCrackUrl($aRead[2]) $aRead = _WinHttpSimpleFormFill($hConnect, $aURL[6] & $aURL[7], Default, "name:file1", $sPic, "[RETURN_ARRAY]") $aURL = _WinHttpCrackUrl($aRead[2]) $aRead = _WinHttpSimpleFormFill($hConnect, $aURL[6] & $aURL[7], "index:0", "name:view_photo", True, "[RETURN_ARRAY]") ;<-- Suppose to press on Add More photos isn't? $aURL = _WinHttpCrackUrl($aRead[2]) $aRead = _WinHttpSimpleFormFill($hConnect, $aURL[6] & $aURL[7], Default, "name:file1", $sPic2, "[RETURN_ARRAY]") ; <-- also submit second photo? $aURL = _WinHttpCrackUrl($aRead[2]) _WinHttpSimpleFormFill($hConnect, $aURL[6] & $aURL[7], Default, "name:view_post", True) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) I'm trying to post multi photos in group, but no luck. Here is idea I came from: