I have a web application that often calls TIdHTTP calls to the Google Analytics API (about 25,000-50,000 per day). Everyone so often turns to the API with an error message in the subject line (not often - less than 1 out of 1000 times). I could never find a pattern to make it happen. And retrying the failed call usually works. So it seems completely random.
I have the latest version of openssl (1.0.2.1 - 03/20/2015). And the latest version of Indy (source files from 01/07/2015).
Below is the basic source code for these calls.
Anyone have any idea what this might be?
Will making two simultaneous API calls affect things (this happens in a multi-threaded web application)?
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=..........');
Update 1 update some lines of code to:
SSLOptions.Method := sslvSSLv3; SSLOptions.SSLVersions := [sslvSSLv3];
It works. I will keep track of SSL errors.
Solution Turns off sslVSSLv3 changes. I no longer get errors! This is somewhat surprising since most other services use TLS instead.
source share