rolkey / indyproject

Automatically exported from code.google.com/p/indyproject
0 stars 0 forks source link

EIdReadTimeout in IdHttp with SSL over Proxy on IIS #279

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When using TIdHTTP.Get() to communicate with IIS from an iOS app, a problem 
occurs that only appears when using SSL over a proxy server. The code works 
fine if HTTP is used over proxy, or no proxy is used at all (both HTTP and 
HTTPS work without proxy).

Calling TIdHTTP.Get() the first time works, but on the second Get() an 
EIdReadTimeout is raised.  When keep-alive is disabled on IIS, the code works 
without a problem.

I suspect (but have not confirmed yet) that after the first Get(), subsequent 
Get() calls may be trying to send a CONNECT request directly to IIS and not to 
the proxy server, and IIS is ignoring the CONNECT request and not sending a 
reply back (or is otherwise sending a reply that TIdHTTP is not reading 
correctly). When an HTTP keep-alive is used, TIdHTTP would maintain the socket 
connection with the proxy and not disconnect (unless the ProxyServer/ProxyPort 
properties are changed). When sending multiple HTTPS requests back to back over 
a kept-alive connection, TIdHTTP does not know that it has already established 
a proxy connection during the first Get() and is likely trying to create the 
proxy connection again during subsequent Get() calls, but it does not need to 
do that.

Original issue reported on code.google.com by gambit47 on 24 Feb 2014 at 6:06

GoogleCodeExporter commented 8 years ago
Issue 280 has been merged into this issue.

Original comment by gambit47 on 27 Feb 2014 at 6:44

GoogleCodeExporter commented 8 years ago
As suspected, when TIdHTTP connects to an HTTP proxy (both SSL and non-SSL) and 
keep-alive is enabled, after the first request is finished TIdHTTP tries to 
send a CONNECT request again on subsequent requests, but the CONNECTs are sent 
directly to the target HTTP server and to the proxy.  This is causing timeout 
errors in TIdHTTP if the server does not reply to the CONNECTs (it appears that 
IIS does not).

When an HTTP keep-alive is used, TIdHTTP maintains the socket connection with 
the proxy and does not disconnect unless its ProxyServer/ProxyPort properties 
are changed or the proxy/target closes the connection.

When sending multiple HTTP requests over a kept-alive proxy connection, TIdHTTP 
needs to check if it is already connected to a proxy and not send CONNECT more 
than once.

Original comment by gambit47 on 27 Feb 2014 at 6:44

GoogleCodeExporter commented 8 years ago

Original comment by gambit47 on 8 Apr 2014 at 1:57

GoogleCodeExporter commented 8 years ago

Original comment by gambit47 on 22 Jul 2014 at 12:54