Jump to content

obj error


Recommended Posts

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

Link to comment
Share on other sites

  • Developers

@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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

What happens when you try to go to https://www.google.com in a browser?  Are you going through a proxy server?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...