Jdop Posted May 20, 2016 Share Posted May 20, 2016 I've run code that accesses this webpage (for years!) and its worked fine under Autoit until recently. http://www.trade-ideas.com/SingleAlertType/NHP/New_high.html I am assuming they added something to the html code that is causing the program to hang up, but after running a trace, it stops executing at this line of code , after running for 5 to 10 seconds in a loop. $msg = GUIGetMsg() Makes little sense on the face of it, but could there be something in html loaded with _IECreateEmbedded() , that could cause this? I made no changes of any kind to the codebase, which makes me think it's the webpage contents. The program itself quite large and unwieldy, so I'm not posting it at this time. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 20, 2016 Developers Share Posted May 20, 2016 It will "only" pause for 10 msecs at that statement, so doubt it is hanging there. 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 More sharing options...
Jdop Posted May 20, 2016 Author Share Posted May 20, 2016 (edited) Yep, thats the last line of code executing before the whole thing comes to a screaming halt. I know its odd. No timeout, no error thrown. Thinking maybe some stack issue, but as I said, I made NO changes to code and dont know how the html in the page could cause that . This is code that has run daily for YEARS without issue. One hint, The page load itself was taking forever, where it was instant before whatever change occured, I added _IELoadWaitTimeout(3000) To get it to load the data , which is another clue that its something on the page causing it. Didn't need it before. Look at the url I posted and see if there's anything in there. Edited May 20, 2016 by Jdop Link to comment Share on other sites More sharing options...
Jdop Posted May 22, 2016 Author Share Posted May 22, 2016 (edited) No question its that web page, which , I think is a lot larger in terms of code size than it used to be, 600k vs 60k. It hangs as I said after about 8 seconds, exactly on the $msg = GUIGetMsg() line, and then goes into a high cpu usage state, where the process continues to gobble memory. Seems like a strange place for code to stop running but its 100% consistent, every time. Edited May 22, 2016 by Jdop Link to comment Share on other sites More sharing options...
argumentum Posted May 22, 2016 Share Posted May 22, 2016 On 5/20/2016 at 10:17 PM, Jdop said: I've run code that accesses this webpage (for years!) and its worked fine under Autoit until recently. http://www.trade-ideas.com/SingleAlertType/NHP/New_high.html OK, this will help you. expandcollapse popupGlobal $aURL = _HTTPGetByUrl("http://www.trade-ideas.com/SingleAlertType/NHP/New_high.html",1) ConsoleWrite($aURL[7][1]) ;~ _ArrayDisplay($aURL) Func _HTTPGetByUrl($sURL, $iStartupTCP = 0, $iTcpTimeoutWithoutReceiving = 600, $iTcpTimeoutWhileReceiving = 60000) If $iStartupTCP Then TCPStartup() Local $tTimer = TimerInit() Local $aURL = _url2hostPage($sURL) Local $iError = @error ReDim $aURL[11][2] $aURL[4][0] = "WSA error" $aURL[5][0] = "debug type number" $aURL[6][0] = "debug type string" $aURL[7][0] = "Received data" $aURL[8][0] = "Total time" $aURL[9][0] = "Received bytes" $aURL[10][0] = "average chunck speed" If Not $aURL[0][0] Then $aURL[4][1] = $iError $aURL[5][1] = 1 $aURL[6][1] = "url2hostPage failed" Return SetError(1, 0, $aURL) EndIf $aURL[0][0] = 10 $iError = @error If $iError Then $aURL[4][1] = $iError $aURL[5][1] = 2 $aURL[6][1] = "TCPStartup failed" Return SetError(2, 0, $aURL) EndIf Local $sName_To_IP = TCPNameToIP($aURL[1][1]) $iError = @error If $iError Then $aURL[4][1] = $iError $aURL[5][1] = 3 $aURL[6][1] = "TCPNameToIP failed" Return SetError(3, $iError, $aURL) EndIf Local $iSocket = TCPConnect($sName_To_IP, $aURL[0][1]) $iError = @error If $iSocket = -1 Or $iError Then TCPCloseSocket($iSocket) $aURL[4][1] = $iError $aURL[5][1] = 4 $aURL[6][1] = "TCPConnect failed" Return SetError(4, 0, $aURL) EndIf Local $sCommand = "GET " & $aURL[2][1] & " HTTP/1.1" & @CRLF $sCommand &= "Host: " & $aURL[1][1] & @CRLF $sCommand &= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0 SMSviaWEB/0.0.0.4" & @CRLF $sCommand &= "Referer: " & $aURL[1][1] & @CRLF ;~ $sCommand &= "Content-Encoding: gzip, deflate" & @CRLF ; remove this =) $sCommand &= "Connection: close" & @CRLF & @CRLF Local $BytesSent = TCPSend($iSocket, $sCommand) If $BytesSent = 0 Then $aURL[4][1] = @error $aURL[5][1] = 5 $aURL[6][1] = "TCPSend HTTP command failed" Return SetError(5, 0, $aURL) EndIf Local $sRecv = "", $sCurrentRecv = "" Local $tRecv = TimerInit() Local $iRecvChunk = 0 Local $tRecvChunk = TimerInit() Local $iErrorInLoop = 0 Local $sError = "" Local $averageChunck = 0 While 1 If GUIGetMsg() = -3 Then ExitLoop $sCurrentRecv = TCPRecv($iSocket, 1024) ; 16 If @error <> 0 Then $iErrorInLoop = @error $iError = 6 $sError = "TCPRecv failed" ExitLoop EndIf If $sCurrentRecv <> "" Then $tRecv = TimerInit() $sRecv &= $sCurrentRecv ;~ ConsoleWrite("--- >" & $sCurrentRecv & "< --- ms.: " & TimerDiff($tRecvChunk) & @CRLF) If $iRecvChunk Then $averageChunck = ($averageChunck + TimerDiff($tRecvChunk)) / $iRecvChunk $iRecvChunk += 1 $tRecvChunk = TimerInit() EndIf If $sRecv And TimerDiff($tRecv) > $iTcpTimeoutWhileReceiving Then $sError = "data receiving stopped ( " & $iTcpTimeoutWhileReceiving & " ms. timeout )" $iError = 7 ExitLoop EndIf If TimerDiff($tRecv) > $iTcpTimeoutWithoutReceiving Then $sError = "no data received ( " & $iTcpTimeoutWithoutReceiving & " ms. timeout )" $iError = 8 ExitLoop EndIf WEnd TCPCloseSocket($iSocket) If $iStartupTCP Then TCPShutdown() $aURL[4][1] = $iErrorInLoop $aURL[5][1] = $iError $aURL[6][1] = $sError $aURL[7][1] = $sRecv $aURL[8][1] = TimerDiff($tTimer) $aURL[9][1] = BinaryLen(Binary($sRecv)) $aURL[10][1] = $averageChunck Return SetError($iError, $aURL[9][1], $aURL) EndFunc ;==>_HTTPGetByUrl Func _url2hostPage($sURL) Local $a[4][2] $a[0][0] = 3 $a[0][1] = "" ; port # based on Protocol or URL ":" divisor $a[1][0] = "Host" $a[2][0] = "Page" $a[3][0] = "protocol" Local $iPortFor_FTP = 21 ; File Transfer Protocol (FTP) Local $iPortFor_SSH = 22 ; Secure Shell (SSH) Local $iPortFor_SMTP = 25 ; Simple Mail Transfer Protocol (SMTP) Local $iPortFor_DNS = 53 ; Domain Name System (DNS) service Local $iPortFor_HTTP = 80 ; Hypertext Transfer Protocol (HTTP) used in the World Wide Web Local $iPortFor_POP3 = 110 ; Post Office Protocol (POP3) Local $iPortFor_NNTP = 119 ; Network News Transfer Protocol (NNTP) Local $iPortFor_NTP = 123 ; Network Time Protocol (NTP) Local $iPortFor_IMAP = 143 ; Internet Message Access Protocol (IMAP) Local $iPortFor_SNMP = 161 ; Simple Network Management Protocol (SNMP) Local $iPortFor_IRC = 194 ; Internet Relay Chat (IRC) Local $iPortFor_HTTPS = 443 ; HTTP Secure (HTTPS) Local $i1 = StringInStr($sURL, "://") If Not $i1 Then $a[0][0] = 0 Return SetError(1, 0, $a) EndIf Local $i2 = StringInStr($sURL, "/", 0, 3) If Not $i2 Then $a[0][0] = 0 Return SetError(2, 0, $a) EndIf $a[1][1] = StringMid($sURL, $i1 + 3, $i2 - $i1 - 3) $b = StringSplit($a[1][1], ":") ReDim $b[3] $a[1][1] = $b[1] If Int($b[2]) Then $a[0][1] = Int($b[2]) ; port from URL $a[2][1] = StringTrimLeft($sURL, $i2 - 1) $a[3][1] = StringLeft($sURL, $i1 - 1) If Int($a[0][1]) = 0 Then $a[0][1] = Eval("iPortFor_" & $a[3][1]) ; port from URL not found, use protocol's port If Int($a[0][1]) = 0 Then $a[0][1] = 80 ; port not found, use "port 80" as default Return SetError(0, 0, $a) EndFunc ;==>_url2hostPage so you can debug your code. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Jdop Posted May 23, 2016 Author Share Posted May 23, 2016 After adding the needed #include <Array.au3>, I ran the code No website passes this test, so Im not sure what this is supposed to do for me. Link to comment Share on other sites More sharing options...
argumentum Posted May 23, 2016 Share Posted May 23, 2016 10 hours ago, Jdop said: No website passes this test, so Im not sure what this is supposed to do for me. The code does the TCP itself, so no libraries would be at fault. I run the code on my side and it downloaded the page. Know not why would not work for you. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Jdop Posted May 23, 2016 Author Share Posted May 23, 2016 (edited) Running that code for https://weather.com/weather/today/l/11229:4:US I get this result 10|443 Host|weather.com Page|/weather/today/l/11229:4:US protocol|https WSA error|10054 debug type number|6 debug type string|TCPRecv failed Received data| Total time|22.2122211065389 Received bytes|0 average chunck speed|0 Edited May 24, 2016 by Jdop Link to comment Share on other sites More sharing options...
argumentum Posted May 24, 2016 Share Posted May 24, 2016 20 minutes ago, Jdop said: Running that code for www.google.com I get yes, that is true for http://www.google.com , yep. Try http://www.google.com/ This code should work on any version 3.3.x.x of autoit. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Jdop Posted May 24, 2016 Author Share Posted May 24, 2016 (edited) Yes, I saw that was the issue with that particular error, but still getting bad results no matter what. For the revised google url I get Row|Col 0|Col 1 [0]|10|80 [1]|Host|www.google.com [2]|Page|/ [3]|protocol|http [4]|WSA error|-1 [5]|debug type number|6 [6]|debug type string|TCPRecv failed [7]|Received data| [8]|Total time|189.571072241216 [9]|Received bytes|0 [10]|average chunck speed|0 Edited May 24, 2016 by Jdop Link to comment Share on other sites More sharing options...
Jdop Posted May 24, 2016 Author Share Posted May 24, 2016 Finally got google to return some data, but my original url (tradeideas.com) still returning nothing Link to comment Share on other sites More sharing options...
argumentum Posted May 24, 2016 Share Posted May 24, 2016 do you have a software firewall ?, use a proxy ?, or any other deterrent ? [4]|WSA error|-1 = invalid socket. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Jdop Posted May 24, 2016 Author Share Posted May 24, 2016 (edited) Nothing beyond Windows 7 Firewall, and having no issues other than this autoit program. All sites load fine under all browsers. Even when the google page returns data, it still throws that [4]|WSA error|-1 Edited May 24, 2016 by Jdop Link to comment Share on other sites More sharing options...
argumentum Posted May 24, 2016 Share Posted May 24, 2016 don't know how else to help, I go to http://www.trade-ideas.com/ and get: HTTP/1.1 200 OK Date: Tue, 24 May 2016 00:18:06 GMT Server: Apache/2.2.22 (Fedora) X-Powered-By: PHP/5.3.20 X-Pingback: http://www.trade-ideas.com/xmlrpc.php ... ... so, try the code on another PC or maybe a virtual PC ( if another PC is not at hand ) to rule out your current PC producing the fault somehow. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Jdop Posted May 24, 2016 Author Share Posted May 24, 2016 (edited) Tried it on a VM with the most recent Autoit build, and it seems to work. Now I have see what the real issue is. I'm going to install the most recent version of Autoit on my production machine and see if that makes a difference. Edited May 24, 2016 by Jdop argumentum 1 Link to comment Share on other sites More sharing options...
Jdop Posted May 24, 2016 Author Share Posted May 24, 2016 I had already tested my original problem on the VM without any luck, so this may be a different issue altogether, Link to comment Share on other sites More sharing options...
Jdop Posted May 24, 2016 Author Share Posted May 24, 2016 Well, the problem with the code you supplied is solved by updating the install. Seems something in the old version wasn't kosher. My problem with that website (tradeideas) remains unsolved. Pretty sure its garbage they added to the web page, I'd have to rewrite my code to avoid the issue. Link to comment Share on other sites More sharing options...
Jdop Posted June 3, 2016 Author Share Posted June 3, 2016 fwiw, I was right, something that happens a lot. Finally figured out how to deal with the garbage they inserted using the hosts file, blocking the site. so I didn't have to rewrite code. Thing is, how some embedded javascript could cause guigetmsg to hang like that is really strange. Some kind of timer it seems , after 10 seconds, it kicked in and hung everything. Link to comment Share on other sites More sharing options...
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