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..

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;

Open in new window

nickdelphi777Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nickdelphi777Author Commented:
Test it yoruself.

procedure TForm1.Button11Click(Sender: TObject);
var
  HTTP:THTTPSend;
  NewUrl:String;
  n: integer;
  SL:TStringList;
  retries:integer;

begin

  HTTP := THTTPSend.Create;


          http.Sock.SocksType := ST_socks5;


            http.Sock.SocksUsername := 'jillsmith78x';
            http.Sock.SocksPassword := 'shotgun19';

            http.Sock.SocksIP := '208.100.27.152';
            http.Sock.SocksPort := '61336';

       

      if HTTP.HTTPMethod('GET','https://www.facebook.com') then
        begin

        showmessage('success');
      end else begin
        showmessage(http.Sock.LastErrorDesc);

      end;
http.free;
end;

Open in new window

0
jimyXCommented:
Not only "Facebook", also "Twitter",  got the same message.
Consider trying different proxy in case that proxy server filters social sites.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jimyXCommented:
Without the proxy it returns success.
0
nickdelphi777Author Commented:
Yeah I think thats it.. thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.