php.net |  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: -
Votes:16
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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: maciej dot lizewski at 3e dot pl
New email:
PHP Version: OS:

 

 [2015-06-09 09:28 UTC] maciej dot lizewski at 3e dot pl
Description:
------------
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( 'https://webapi.allegro.pl/service.php?wsdl', array( 'proxy_host'=>'[proxy host]', 'proxy_port'=>3128, 'cache_wsdl'=>WSDL_CACHE_BOTH, 'stream_context'=>$context ) );

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

try{
    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.

Patches

Pull Requests

Pull requests:

History

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);
    zval_ptr_dtor(&ssl_proxy_peer_name);
}
---------------

I'm maybe wrong but at least this workaround fixed the issue for me.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 22:01:33 2024 UTC