Jump to content
Sign in to follow this  

some winHTTP requests are not processed

Recommended Posts


At the moment i have a php file that gathers data from a specific link and stores it in a database. If i let the php file write every link that needs to be processed it doesn't correspond with the amount of requests made. So i suspect that somehow all these fast requests, which are a few thousand, are not all processed. Does this script keep making new connections or does it use one only? It seems that somehow too many connections are made and not all requests come through. I am just guessing and debugging didn't help me so far.

Here is the part of my code i am talking about. $links is an array with all the links that need to be processed.

func get_data($links)
Local $hOpen, $hConnect, $hRequest
$hOpen = _WinHttpOpen()  
$hConnect = _WinHttpConnect($hOpen, "localhost")     

For $i = 2 to UBound($links)-1 Step 1
$hRequest=_WinHttpOpenRequest($hConnect, "GET", "/get_data.php?linkid="& $links[$i], "HTTP/1.1",$WINHTTP_NO_REFERER,"*/*")     

if NOT _WinHttpSendRequest($hRequest, $WINHTTP_NO_ADDITIONAL_HEADERS) Then
ConsoleWrite("request not done, error is: " & @error & @CRLF & @CRLF)   



i did some more debugging while this thread is up. It seems that suddenly the amount of connection is too much indeed. I get a @error=1 after a lot of connections and then it seems only new connections are made if there is a spot open.

my current new solution is to just try to make the request until it works again with a sleep if a few seconds in between tries. Any other ideas on how to solve this?

Edited by cageman

Share this post

Link to post
Share on other sites

_WinHttpCloseHandle($hRequest) should be inside the loop.

Currently you are closing only the last one.




Share this post

Link to post
Share on other sites

Thx, hopefully that is the mistake that caused it.

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

Sign in to follow this  


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.