HTTPS post - what I'm doing wrong?

Posted by evilone on Stack Overflow See other posts from Stack Overflow or by evilone
Published on 2010-12-23T05:39:52Z Indexed on 2010/12/26 7:54 UTC
Read the original article Hit count: 236

Filed under:
|
|
|

Hi,

I'm making requests to the webaddress to get XML files throught the HTTPS connection. But this connection works like 50%. In most cases it fails. Usual error is "socket error #10060". Or "Error connecting with SSL. EOF was observed that violates the protocol". What I'm doing wrong?

function SendRequest(parameters: string): IXMLDocument;
var
   sPostData: TStringList;
   sHttpSocket: TIdHTTP;
   sshSocketHandler: TIdSSLIOHandlerSocketOpenSSL;
   resStream: TStringStream;
   xDoc: IXMLDocument;

   begin
      sPostData := TStringList.Create;

      try
         sPostData.Add('add some parameter to post' + '&');
         sPostData.Add('add some parameter to post' + '&');
         sPostData.Add('add some parameter to post' + '&');
         sPostData.Add(parameters);

         sHttpSocket := TIdHTTP.Create;
         sshSocketHandler := TIdSSLIOHandlerSocketOpenSSL.Create;
         sHttpSocket.IOHandler := sshSocketHandler;

         sHttpSocket.Request.ContentType := 'application/x-www-form-urlencoded';
         sHttpSocket.Request.Method := 'POST';

         resStream := TStringStream.Create;
         sHttpSocket.Post(Self.sUrl, sPostData, resStream);

         xDoc := CreateXMLDoc;
         xDoc.LoadFromStream(resStream);

         Result := xDoc;

         resStream.Free;
         sHttpSocket.Free;
         sshSocketHandler.Free;
         sPostData.Free;
      except on E: Exception do
      begin
         TCommon.ErrorLog('errorLog.txt', DateTimeToStr(Now) + ' ' + E.Message);
      end
      end;
    end;

Maybe I can do this in another way, that works like 100%, when internet connection is available?

Regards, evilone

© Stack Overflow or respective owner

Related posts about delphi

Related posts about post