Solved

Problem with "default_socket_timeout"

Posted on 2008-06-10
6
11,054 Views
Last Modified: 2012-06-27
hi,

I recently started having issues with response times from a Web Service I use.
The responses were taking over 2 minutes at times to come back whereas normally they are less than a second.

i tried adding the folliwng to my scripts...

ini_set('default_socket_timeout', 15);

but this has had absolutely no effect. also, is the default not 60 seconds?

any help would be appreciated

thanks
0
Comment
Question by:Fatlog
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:rhickmott
ID: 21758804
Its normally 60s yes but I cant recall whether the 30s default script execution time kicks in or not.

It all depends where the problem lies. How are you recalling data? socket_timeout only applies to connecting sockets however if the socket connects but the server is not sending anything then the stream can sit there until the script times out.

How are you requesting the data?
0
 

Author Comment

by:Fatlog
ID: 21758856
they are all SOAP connections using soapClient() in PHP 5. I connect to the Web Service Endpoint and then make a request to one of the API methods and wait for the response.

The connection to the Web Service is fine. the problem occurs when callinag a specific API method. 99.9% of the time it works fine. i might call this method a 1000 times a day and only a handful will encounter this problem.

i accept that i may encounter probelms connecting to web services at times, however i would like to timeout on the request after 10 to 15 seconds if i haven't gotten a response.

0
 
LVL 13

Expert Comment

by:rhickmott
ID: 21758969
Ah well the soapClient is a seperate class ( pear/pcl ? ) it will prob have its own methods for setting stream/socket timeouts which will override anything you set in your php.

socket_timeout applies to sockets opened by you.

A quick bit of google shows that this appears to be a undocumented parameter.

$client = new SoapClient($wsdl, array("connection_timeout"=>5));

Basically wherever you call the Soap Class it takes in an array of parameters just add the "connection_timeout" to it and see if that works.


0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Fatlog
ID: 21759085
thanks for the swift replies!

the soapClient class is part of PHP 5.
i have specified the connection as you recommend; however, this does not do what you would expect it to!

this is from the PHP manual(http://ie.php.net/soap-soapclient-construct), which i looked up when i started to encounter this error...

################################################################################
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.
################################################################################

so the timeout only handles the initial connectio to the SOAP service and not subsequent calls to slow services.
When i found this i then implemented the suggested 'default_socket_timeout' which does not appear to have any affect on slow services!?!?



0
 
LVL 13

Accepted Solution

by:
rhickmott earned 75 total points
ID: 21759942
Is suspect the soap class will set its own time-outs and script timeouts. You would prob have to go delving though the code of the class itself and follow it though to find out where and when it sets its timeouts.

Most scripts will ini_set their own time-out and then reset it as the class terminates to ensure that you dont get problems with code or settings in other classes. they really should have made this settable though.
0
 

Author Comment

by:Fatlog
ID: 22033869
hhhmmm,

sorry about the delay in getting back to this question.
this problem seems to have been sorted without me doing anything new.

the 'default_socket_timeout' seems to work now. no idea why it wasn't before - unless the problem wasn't with that!??!

anyway. all is good now.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question