title: "1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number call:" on Indy
body: <p>I have a web app that makes frequent <strong>TIdHTTP</strong> calls to the Google Analytics API (around 25,000-50,000 per day).  Every so often calls to the API fail with the error message in the subject line (not often - less than 1 out of 1000 times).  I have never been able to find a pattern to get it to happen.  And retrying the failed call usually works.  So it seems entirely random.</p>
  
  <p>I have the latest version of openssl (1.0.2.1 - 03/20/2015).  And the latest version of Indy (source code files dated 01/07/2015).</p>
  
  <p>Below is the basic source code for making these calls.</p>
  
  <p>Anyone have any ideas what it could be?  </p>
  
  <p>Would making two simultaneous calls to the API affect things (this is taking place in a multi-threaded Web App)?</p>
  
  <pre><code>IdSSLIOHandlerSocket1 := TIdSSLIOHandlerSocketOpenSSL.create(nil);
  IdSSLIOHandlerSocket1.PassThrough := True;
  IdHTTP := TIdHTTP.create(nil);
  IdHTTP.reusesocket := rsTrue;
  IdSSLIOHandlerSocket1.reusesocket := rsTrue;
  idhttp.handleredirects := True;
  with IdSSLIOHandlerSocket1 do begin
    SSLOptions.Method := sslvTLSv1_2;
    SSLOptions.SSLVersions := [sslvTLSv1_2];
    SSLOptions.VerifyMode := [];
    SSLOptions.VerifyDepth := 2;
  end;
  with IdHTTP do begin
    IOHandler := IdSSLIOHandlerSocket1;
    ProxyParams.BasicAuthentication := False;
    Request.UserAgent := 'EmbeddedAnalytics API Interface';
    Request.ContentType := 'text/html';
    request.connection := 'close';
    Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
    Request.BasicAuthentication := False;
    Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)';
    HTTPOptions := [hoForceEncodeParams];
    Request.AcceptEncoding := 'gzip,deflate';
    Request.CustomHeaders.Add('Accept-Language: en-us,en;q=0.5');
    idhttp.Request.CustomHeaders.Add('Authorization: Bearer '+FToken);
  end;
  idhttp.get(':https://www.googleapis.com/analytics/v3/data/realtime?ids=..........');
  </code></pre>
  
  <p><strong>Update 1</strong> update some lines of code to:</p>
  
  <pre><code>SSLOptions.Method := sslvSSLv3;
  SSLOptions.SSLVersions := [sslvSSLv3];
  </code></pre>
  
  <p>It works.  I will monitor and see if SSL errors go away.</p>
  
  <p><strong>Solution</strong> Turns out making the changes to sslVSSLv3 fixed it.  I no longer get the errors!  This is somewhat surprising seeing that most all other services are adopting TLS instead.</p>