SoapFault exception: Could not connect to host

后端 未结 27 1517
-上瘾入骨i
-上瘾入骨i 2020-12-01 07:47

Sometimes fail to call the web service.

This problem happens all the time.

What could be the problem?

Error:
    SoapFault exception: [HTTP]          


        
相关标签:
27条回答
  • Another possible reason for this error is when you are creating and keeping too many connections open.

    SoapClient sends the HTTP Header Connection: Keep-Alive by default (through the constructor option keep_alive). But if you create a new SoapClient instance for every call in your queue, this will create and keep-open a new connection everytime. If the calls are executed fast enough, you will eventually run into a limit of 1000 open connections or so and this results in SoapFault: Could not connect to host.

    So make sure you create the SoapClient once and reuse it for subsequent calls.

    0 讨论(0)
  • 2020-12-01 08:35

    The host is either down or very slow to respond. If it's slow to respond, you can try increasing the timeout via the connection_timeout option or via the default_socket_timeout setting and see if that reduces the failures.

    http://www.php.net/manual/en/soapclient.soapclient.php

    http://www.php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout

    You can also include error handling as zanlok pointed out to retry a few times. If you have users actually waiting on these SOAP calls then you'll want to queue them up and process them in the background and notify the user when they're finished.

    0 讨论(0)
  • 2020-12-01 08:35

    I finally found the reason,its becuse of the library can't find a CA bundle on your system. PHP >= v5.6 automatically sets verify_peer to true by default. However, not all systems have a known CA bundle on disk .

    You can try one of these procedures:

    1.If you have a CA file on your system, set openssl.cafile or curl.cainfo in your php.ini to the path of your CA file.

    2.Manually specify your SSL CA file location

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);  
    curl_setopt($cHandler, CURLOPT_CAINFO, $path-of-your-ca-file);
    

    3.disabled verify_peer

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    0 讨论(0)
提交回复
热议问题