nickdelphi777
asked on
Delphi Proxy Problem (http and socks5) 10091 Network subsystem is unusable
I am using HTTPSEND (synapse) to grab facebook.com.. when i set a HTTP or Socks5 proxy i always get this error:
WinSock Error: 10091 Network subsystem is unusable
If i try to grab any other website (even with https://) with the proxies on.. it grabs the pages fine.
Why does only facebook.com produce this error? I have both required .dlls and i am calling ssl_openssl
please help..
WinSock Error: 10091 Network subsystem is unusable
If i try to grab any other website (even with https://) with the proxies on.. it grabs the pages fine.
Why does only facebook.com produce this error? I have both required .dlls and i am calling ssl_openssl
please help..
function TBaseThread.doGet(url: string; useragent: string; UseProxy:Integer) : string;
var
HTTP:THTTPSend;
NewUrl:String;
n: integer;
SL:TStringList;
retries:integer;
begin
result:= ''; // or use 'error codes' in the result, similar to the debug messages
retries := 1;
SL:=TStringList.Create;
HTTP := THTTPSend.Create;
repeat
http.Clear;
http.sock.ResetLastError;
CookieStream.Position := 0;
HTTP.Cookies.LoadFromStream(CookieStream);
HTTP.UserAgent := useragent;
HTTP.KeepAlive := true;
HTTP.KeepAliveTimeout := connecttimeout;
HTTP.Timeout := connecttimeout;
HTTP.TargetPort := '80';
HTTP.TargetHost := url;
HTTP.Protocol :='1.1';
HTTP.MimeType :='application/x-www-form-urlencoded';
http.Sock.SetRecvTimeout(readtimeout);
if UseProxy = 1 then
begin
if(ptype = 'socks4')then
begin
http.Sock.SocksType := ST_socks5;
if (pUser <> '') and (pPass <> '') then
begin
http.Sock.SocksUsername := pUser;
http.Sock.SocksPassword := pPass;
end;//if username and pass
http.Sock.SocksIP := pHost;
http.Sock.SocksPort := pPort;
end
else
begin
http.Sock.HTTPTunnelTimeout := connecttimeout;
if (pUser <> '') and (pPass <> '') then
begin
HTTP.ProxyHost := pHost;
HTTP.ProxyPort := pPort;
HTTP.ProxyUser := pUser;
HTTP.ProxyPass := pPass;
addlog(pUser + ':'+ppass);
end
else
begin
HTTP.ProxyHost := pHost;
HTTP.ProxyPort := pPort;
HTTP.ProxyUser := '';
HTTP.ProxyPass := '';
end;
end;
end;
repeat
http.clear;
if HTTP.HTTPMethod('GET',url) then
begin
n := FoundLocationStrNum(HTTP.Headers);
if (n >= 0) and (n <= HTTP.Headers.count) then
begin
try
NewUrl := StringReplace(HTTP.Headers.Strings[n],'Location: ','',[]);
except
addlog('Error with headers stringreplace 3');
end;
newurl := StringReplace(newurl, ':443', '',[rfReplaceAll, rfIgnoreCase]);
url:= newurl;
end;
end;
until not(HTTP.Resultcode = 301) and not(HTTP.Resultcode = 302) and not(HTTP.Resultcode = 307); //and (HTTP.Resultcode = 200)
//error checking and retrying
if((http.Sock.LastError <> 0) or (http.Document.Size <= 0)) then
begin
addlog( http.Sock.SSL.LastErrorDesc);
addlog('GET WinSock Error: '+inttostr(http.Sock.LastError) + ' ' + http.Sock.GetErrorDescEx);
inc(retries);
addlog('Retrying connection...GET');
sleep(1000);
end
else // or use if success-condition then
begin
//Clear SL String List, and load http into it
sl.Clear;
http.Document.Position := 0;
SL.LoadFromStream(HTTP.Document);
if(pos('Redirecting...',sl.Text) > 0) then
begin
newurl := findvalue2('url=',sl.Text,'"');
http.Clear;
HTTP.HTTPMethod('GET',newurl);
sl.Clear;
http.Document.Position := 0;
SL.LoadFromStream(HTTP.Document);
end;
end;
until ((http.Sock.LastError = 0) or (http.Document.Size > 0)) or (retries > retryattempts);
//save new cookie to stream
CookieStream.Position := 0;
if CookieStream <> nil then
HTTP.Cookies.SaveToStream(CookieStream);
//write debug
if(debugmode) then
begin
if(not(directoryexists('debug')))then
begin
createdir('debug');
end;
// addlog('write debug');
sl.Add(URL);
sl.SaveToFile('debug/GET_'+email+'_Action_'+inttostr(debugpos)+'_.html');
inc(debugpos);
end;
//return result text
Result:= SL.Text;
SL.Free;
HTTP.Free;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Without the proxy it returns success.
ASKER
Yeah I think thats it.. thanks
ASKER
Open in new window