php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48584 soapclient's option connection_timeout not respected while fetching wsdl
Submitted: 2009-06-17 14:18 UTC Modified: 2009-06-24 07:55 UTC
Votes:21
Avg. Score:4.7 ± 0.5
Reproduced:19 of 19 (100.0%)
Same Version:4 (21.1%)
Same OS:3 (15.8%)
From: giunta dot gaetano at gmail dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.2.9 OS: winxp
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:
MUST BE VALID
Solve the problem:
5 - 1 = ?
Subscribe to this entry?

 
 [2009-06-17 14:18 UTC] giunta dot gaetano at gmail dot com
Description:
------------
The socket timeout option for soap clients is only respected when executing calls, but not when fetching the wsdl itself.
This makes it quite hard to use remote wsdl files and provide to the end user an interface with a definite timeout (eg. 5 secs).
Current code does not seem to use the timeout value in c function get_sdl in php_sdl.c

Reproduce code:
---------------
create a soap client pointing to a wsdl on an inexisting server
set connection_timeout option to 5 in client constructor


Expected result:
----------------
error msg after 5 secs

Actual result:
--------------
error msg after 1 min

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-23 19:20 UTC] sjoerd-php at linuxonly dot nl
Thank you for your bug report.

The connection_timeout option defines a timeout in seconds for the connection to the SOAP service. This option does not define a timeout for services with slow responses. To limit the time to wait for calls to finish the default_socket_timeout setting is available.

<?php
// Wait one second for connection when retrieving WSDL:
ini_set('default_socket_timeout', 1);
new SoapClient('http://123.123.123.123/bla.wsdl');
?>
 [2009-06-24 07:55 UTC] giunta dot gaetano at gmail dot com
Thanks for your comment, that's exactly what I did for my needs.
Still I find it quite cumbersome (and counterintuitive).
Here's a better syntax btw, especially when creating a library and not just a one-page app
<?php
...
// Wait one second for connection when retrieving WSDL:
$deftimeout = ini_get( 'default_socket_timeout' );
ini_set('default_socket_timeout', 1);
try {
  $c = new SoapClient('http://123.123.123.123/bla.wsdl');
  ini_set( 'default_socket_timeout', $deftimeout );
  ...
} catch (exception $e) {
  ini_set( 'default_socket_timeout', $deftimeout );
  ...
}

?>
 [2011-09-29 18:31 UTC] tanealbhandari at gmail dot com
Will setting a value for 'default_socket_timeout' work for SSL connections?
 [2013-02-17 17:53 UTC] bcware at gmail dot com
The issue described is not related to total execution time. That is consistently 
controlled by the default_socket_timeout and a separate issue.

The issue is with the timeout to retrieve the WSDL when the SoapClient object is 
created. If the SOAP server does not response to the WSDL request, the SoapClient 
on Win will wait for full default_socket_timeout before returning.

The workaround to set a global value is very clumsy. It seems that the WSDL 
request should either respect the connection_timeout for the soap request, or 
have its own parameter.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 23 04:01:27 2019 UTC