I\'m trying to invoke a WS over https on a remote host:remote port and I get:
Error fetching http headers
using the PHP5 SoapCli
We encountered Error fetching http headers on every second call of SoapClient::__soapCall(,). However, not every soap endpoint/soap server was affected.
It turned out that switching to http was working reliably for all servers, but connections via https/secure HTTP showed above symptoms.
The openssl_error_string() as suggested by Furgas did not return any errors.
It turned out that the misbehaving soap servers sent a HTTP-header with every response which lead to the soap client choking on the second soap call:
Connection: Upgrade, close. The well-behaving servers did not send a Upgrade on successive responses.
What worked for us:
keep_alive to false, as mentioned by ThiagoAlthough the well-behaving soap servers did not need any of this, the misbehaving once needed both the keep_alive set to false and the unsetting of the headers.
# .htaccess
Header unset Upgrade
Header unset Connection
The root-cause is still unclear, but there is a bug report at Apache regarding Upgrade headers when using HTTPS.