nhocquan Posted September 15, 2016 Posted September 15, 2016 (edited) Hi everyone, I have a script that call this function again & again normaly Func CallAPI($amount, $target, $condition, $API_key) $oHTTP.Open("POST","https://HOST?api_key="&$API_key) $oHTTP.SetRequestHeader('content-type','application/json') $oHTTP.Send('{"amount":'&$amount&',"target":'&$target&',"condition":"'&$condition&'"}') $Response = $oHTTP.ResponseText Return $Response EndFunc but sometime (may be after 105 request, 203 request, 1000 request, ... n request) this request error and make my script stop $oHTTP.Send('{"amount":'&$amount&',"target":'&$target&',"condition":"'&$condition&'"}') $oHTTP.^ ERROR 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 $oHTTP.SetTimeouts(30000,60000,30000,30000) Spoiler 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. $oHTTP.SetTimeouts(30000,60000,30000,30000) 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 September 15, 2016 by nhocquan
genius257 Posted September 15, 2016 Posted September 15, 2016 The example from the AutoIt documentation (ObjEvent) shows how to: 44 minutes ago, nhocquan said: return error code and countinue code without exit nhocquan 1 To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
nhocquan Posted September 16, 2016 Author Posted September 16, 2016 (edited) 6 hours ago, genius257 said: The example from the AutoIt documentation (ObjEvent) shows how to: Thank you very much Edited September 16, 2016 by nhocquan
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now