Jump to content
haijie1223

obj error

Recommended Posts

haijie1223
Local $url = 'https://www.google.com/'
Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHttp.Open('GET', $url, True)
$oHttp.Send()
$oHttp.WaitForResponse()
Local $NetData = BinaryToString($oHttp.ResponseBody, 4)
ConsoleWrite($NetData)

like  above code,In the 3.3.13.12 is Right。

but in the 3.3.14.0,3.3.14.2,3.3.14.3,3.3.14.4,3.3.14.5 version,is error  As shown below.

5aad20c403ee5_QQ20180317220023.jpg.4c6191cfb3b5eae0c9573e64920b27bb.jpg

Share this post


Link to post
Share on other sites
Jos

@haijie1223,
Moved to the appropriate forum, as the DEV forum very clearly states:

Quote

Do not create AutoIt-related topics here, use AutoIt General Help and Support

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Danyfirex

Hello. Add a COM Error handler to check the issue. I think its a timeout problem probably you can set a higher timeout for the response.

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Local $sUrl = 'https://www.google.com/'
Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHttp.SetTimeouts(0, 60000, 30000, 130000)
;$oHttp.SetTimeouts(ResolveTimeout, ConnectTimeout, SendTimeout, ReceiveTimeout)
;Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/aa384061(v=vs.85).aspx
$oHttp.Open('GET', $sUrl, True)
$oHttp.Send()
Local $x=$oHttp.WaitForResponse()
Local $NetData = BinaryToString($oHttp.ResponseBody, 4)
ConsoleWrite($NetData)


; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

Saludos

Edited by Danyfirex
Fix Code

Share this post


Link to post
Share on other sites
TheXman

The code you posted works just fine for me so Danyfirex is probably right about possibly timing out and that you should add COM error handling.  I forgot to mention that I am using AutoIt v3.3.14.5.  Common things that will cause that error are things like not being able to resolve the address or timing out.  If you use async mode, you will get the error on the WaitForResponse() method.  If you use sync mode, you will get the same error on the Send() method.

Unless for some reason you absolutely have to use ASYNC mode, if you use synchronous  mode, then the Send() method will wait until the response is received - you will not need the WaitForResponse() method.

 

To use synchronous mode, change the 3rd parameter in the Open method from TRUE to FALSE and remove the WaitForResponse.

 

Local $url = 'https://www.google.com/'
Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")
$oHttp.Open('GET', $url, False)
$oHttp.Send()
;~ $oHttp.WaitForResponse()
Local $NetData = BinaryToString($oHttp.ResponseBody, 4)
ConsoleWrite($NetData)

 

https://msdn.microsoft.com/en-us/library/windows/desktop/aa383989(v=vs.85).aspx

 

Edited by TheXman

Share this post


Link to post
Share on other sites
haijie1223

@DanyfirexThanks,but 3.3.13.12 version is not error with no set timeout。3.3.14.3  set higher timeout is error too。

Share this post


Link to post
Share on other sites
haijie1223

@TheXman thanks,but synchronous mode is  error as same as asynchronous mode。

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.