Solved

Problem with "default_socket_timeout"

Posted on 2008-06-10
6
10,745 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

759 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

19 Experts available now in Live!

Get 1:1 Help Now