Solved

Problem with "default_socket_timeout"

Posted on 2008-06-10
6
10,865 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now