Bug #69783 [Com]: Webservice wsdl cache and proxy causes "Could not connect to host" error

From: Date: Fri, 28 Oct 2016 08:55:02 +0000
Subject: Bug #69783 [Com]: Webservice wsdl cache and proxy causes "Could not connect to host" error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205050@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69783&edit=1 ID: 69783 Comment by: regis dot leroy at makina-corpus dot com Reported by: maciej dot lizewski at 3e dot pl Summary: Webservice wsdl cache and proxy causes "Could not connect to host" error Status: Open Type: Bug Package: SOAP related Operating System: Debian Linux PHP Version: 5.6.9 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2016-10-17 15:12:00] paolomainardi at gmail dot com I confirm the very same bug on PHP 7.0.12 ------------------------------------------------------------------------ [2015-06-09 09:28:47] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69783&edit=1

« previous php.bugs (#205050) next »