JayDoubleEw

inetget doesn't work on some sites

16 posts in this topic

#1 ·  Posted

Hey folks,

Long time user of AutoIT, but first time poster since I'm a little lost on this. I've a simple inetget function that works for most of my users except one. Basically my application download several files, parses the contents and display them in the application. However, inetget isn't working for one user.

Here's the code sample - it's mostly just based off the default example

Func DownloadFile($file_to_download, $file_to_saveas)

    ; Download a file in the background.
    ; Wait for the download to complete.
    ; Save the downloaded file to the temporary folder.

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet($file_to_download, $file_to_saveas, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($file_to_saveas)

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; MsgBox("","",$file_to_saveas & @CRLF & $file_to_download)


EndFunc   ;==>DownloadFile

 

One thing I DID notice was that some sites work (e.g. Google), but other internal sites (http/https) does not. Some of those internal sites when browsed via browser requires log in to proceed further, but just downloading the login page (as a test) SHOULD work.

Any ideas, please?

Share this post


Link to post
Share on other sites



#2 ·  Posted

Does that computer have an antivirus/firewall set up? A lot of the time an antivirus will block a script that calls InetGet() because it seems like a "Trojan Downloader."


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#3 ·  Posted

Well, I thought of that, so I tested running inetget against multiple sites in a single executable, and it works on some sites but not others, so I know it's not an AV/FW issue. My best guess at the moment is potentially IE related, but the user is able to access (and download) the files if I use IE directly.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Can you give examples of sites that work and don't work so we can test it ourselves?


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#5 ·  Posted

The sites that don't work for that particular user are internal access only so I'm not sure how we can test it from outside.

The internal sites work for everyone else so I don't think it's the issue with the site but something more localized.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Are the sites that do not work, ones that log you in automatically if you are logged in to the domain?

Share this post


Link to post
Share on other sites

#7 ·  Posted

Nope, the sites that do not work do not log you in automatically. The sites that DO work from testing so far are external internet sites such as google and oddly, our internal SharePoint page.

Share this post


Link to post
Share on other sites

#8 ·  Posted

Are these publicly sold web-based systems, or in-house developed.

If they are publicly sold, if you could at lease let us know what they are, it help us in narrowing down what the issue is.

Share this post


Link to post
Share on other sites

#9 ·  Posted

You haven't really defined what "inetget isn't working for one user" really looks like. How do you know that it isn't working? What are the symptoms?

Have you tried checking the value of @error after the InetGet / InetGetInfo calls?

Share this post


Link to post
Share on other sites

#10 ·  Posted

We have both - an in house developed web system and also a public web system (Atlassian product); both do not work.

 

As for how I know it isn't working - as my first post mentioned; the application download files, reads the content and then displays them out in the AutoIT application. If it fails to download the file, it errors out. To test it further, I did a pure file download app only that saves to temp to see what happens. The @error is zero for ALL sites.  Here's the sample standalone and $dlPath is the URLs

- Just realized my @error may have been at the wrong place though ...

Func Example($dlPath)
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = _WinAPI_GetTempFileName(@TempDir)
    MsgBox('','',$sFilePath)

    ; Read the file without downloading to a folder. The option of 'get the file from the local cache' has been selected.
    Local $dData = InetRead($dlPath)

    ; The number of bytes read is returned using the @extended macro.
    Local $iBytesRead = @extended

    ; Convert the ANSI compatible binary string back into a string.
    Local $sData = BinaryToString($dData)

    ; Display the results.
    MsgBox($MB_SYSTEMMODAL, "", "The number of bytes read: " & $iBytesRead & @CRLF & @CRLF & $sData)

    Local $iSize = InetGetSize($dlPath)
    MsgBox($MB_SYSTEMMODAL, "", "The size of the file: " & $iSize)

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet($dlPath, $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)


    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    ;MsgBox('','',@error)
    Local $iFileSize = FileGetSize($sFilePath)

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the total number of bytes read and the filesize.
    MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _
            "The total filesize: " & $iFileSize)

    ; Delete the file.
    ;FileDelete($sFilePath)
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

I have an Atlassian account I can test against.  Which service is giving the problem?  You don't need to give me any private information, but if you could tell me roughly what you are downloading, I can test from my end and see what I can find.

Share this post


Link to post
Share on other sites

#12 ·  Posted

It's just the login page (e.g. http://internal-crucible:8080) - the application doesn't connect to external Atlassian (or even internal for any POST/GET). I'm just using it for testing. In actual fact, the application connects to an internally developed web-server just to query a file e.g. http://internal-site/files/foo.txt and processes the contents there.

Share this post


Link to post
Share on other sites

#13 ·  Posted

I am not sure how much we will be able to help.  You may need to confer with your internal web developers.

Final two thoughts:

Have you confirmed that the http://internal-site/files/foo.txt file is not empty by manually downloading it?

Have you tried using the same URL you are passing to inetget with WGET to see if it gives the same result?  If you get the same result, then it definitely looks like a problem with the in-house developed page or the server it is running on.

Share this post


Link to post
Share on other sites

#14 ·  Posted

For testing purposes, have you tried removing the background download to see if the file is downloaded by a single call to InetGet?

Share this post


Link to post
Share on other sites

#15 ·  Posted

As mentioned, it's definitely not the server OR the page because everyone else, myself included are running the same application and working fine.

I did find out something though - it turns on when the user launches IE, he's seeing a Security Alert - Revocation information for the security certificate for this site is not available. Could this be the cause? Testing seems to indicate it to be i.e. I can now confirm on the laptop, running InetGet against -> external site, internal site (not using that particular certificate) works. Any site(s) needing the root certificate fails.

My issue is pretty similar to below except this is really old.

 

Share this post


Link to post
Share on other sites

#16 ·  Posted

Are these users all behind the same firewall? Reading this makes it sound like a firewall issue.

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