Summary: PHP’s SOAP client was throwing an extremely unhelpful error: Error Fetching http headers. It turns out that it was a simple case of a slow SOAP server, and increasing the defaultsockettimeout in php.ini to 120 fixed it.
Problem: My very first experience with SOAP was failing. I couldn’t figure out why one request (getVersion) worked while another (getUserList) gave the above cryptic error.
Solution: After trying in vain to get useful information out of Apache and PHP, I installed Wireshark to sniff my network traffic. I could see the response coming in just fine, but it was only when I realized that it was coming in almost 100 seconds after the request that I became suspicious. Checking my php.ini, I found that the defaultsockettimeout was set to 60 seconds. I upped it to 120 and the problem was resolved.
Discussion: I probably should have thought of a timeout earlier. It felt like a timeout, but the strange message about headers caused me to bash my head against a wall for the better part of a workday.
Using the SOAP client’s connection_timeout option in this case would most likely not work because this is not a connection timeout—the TCP connection is made just fine—but rather that the server takes too long to form its HTTP/SOAP response. This is why the call to getVersion ran without trouble while getUserList did not; getUserList had a much longer execution time on the server.
Author
AnonymousDate
February 18, 2009Time
3:02 pmAuthor
Aidan FindlaterDate
February 18, 2009Time
4:47 pmAuthor
Andrew MetcalfeDate
May 15, 2009Time
7:47 amAuthor
PatriciaDate
May 27, 2009Time
8:56 amAuthor
JasonDate
June 16, 2009Time
5:33 amAuthor
Aidan FindlaterDate
June 17, 2009Time
2:57 pmAuthor
Sergey SinitsaDate
August 18, 2009Time
11:26 pmAuthor
RobertDate
June 22, 2011Time
5:14 amAuthor
monnDate
September 20, 2011Time
3:08 am