|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69783 Webservice wsdl cache and proxy causes "Could not connect to host" error
Submitted: 2015-06-09 09:28 UTC Modified: -
Avg. Score:4.6 ± 0.7
Reproduced:15 of 15 (100.0%)
Same Version:4 (26.7%)
Same OS:8 (53.3%)
From: maciej dot lizewski at 3e dot pl Assigned:
Status: Open Package: SOAP related
PHP Version: 5.6.9 OS: Debian Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
27 - 5 = ?
Subscribe to this entry?

 [2015-06-09 09:28 UTC] maciej dot lizewski at 3e dot pl
We need to connect to SSL WebService through Squid proxy.

When we connect with proxy and without wsdl cache (on disk) - it works fine
When we connect without proxy and with wsdl cache (on disk) - it works fine

when we connect with both wsdl cache on disk and proxy - only first request works (which creates cache file). All subsequent calls fail with "Could not connect to host" error. When cache file is wiped out - next request works fine, and again subsequent throw an error.

another thing is that we have to provide proxy configuration in both SoapClient options and Stream Context. When only provided in one place - same error is thrown ("Could not connect to host").

Test script:
$opts = array( 'http'=>array( 'proxy'=>'tcp://[proxy host]:3128' ) );
$context = stream_context_create( $opts );

$client = new SoapClient( '', array( 'proxy_host'=>'[proxy host]', 'proxy_port'=>3128, 'cache_wsdl'=>WSDL_CACHE_BOTH, 'stream_context'=>$context ) );

$request = array(
    'sysvar' => 1,
    'countryId' => 1,
    'webapiKey' => '[secret]'

    var_dump( $client->doQuerySysStatus( $request ) );
}catch(SoapFault $e){
    echo $e->getCode() . ' ' . $e->getMessage() . "\n";

Expected result:
WSDL cache should work and it should use cached data when using proxy.

Actual result:
We can use only wsdl cache or proxy at once. Using both causes connection errors.


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-17 15:12 UTC] paolomainardi at gmail dot com
I confirm the very same bug on PHP 7.0.12
 [2016-10-28 08:54 UTC] regis dot leroy at makina-corpus dot com
Experienced the same problem, windows php 5.6.4.

Found a workaround.

In the stream_context, enforce 'peer_name' in ssl options:

    $opts['ssl']['peer_name'] = '<hostname>';

And the __soapCall can now work with a cached wsdl.

Found this one by reading "ext/soap/php_http.c" source code.
I'm pretty sure this section of code is not executed when context is loaded from the cache -- or something like that --. 

/* Set peer_name or name verification will try to use the proxy server name */
if (!context || (tmp = php_stream_context_get_option(context, "ssl", "peer_name")) == NULL) {
    ZVAL_STRING(&ssl_proxy_peer_name, phpurl->host);
    php_stream_context_set_option(PHP_STREAM_CONTEXT(stream), "ssl", "peer_name", &ssl_proxy_peer_name);

I'm maybe wrong but at least this workaround fixed the issue for me.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 17 20:03:37 2021 UTC