Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with "default_socket_timeout"

Posted on 2008-06-10
6
Medium Priority
?
11,642 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 

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 300 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

Find the IP of a Linux Server in Command Line

Knowing your server’s IP address(s) can be a useful bit of information to have for various reasons. This tutorial will teach you how to check the IPs of any modern Linux server. To follow along will simply need access to the server via SSH or TTY.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

730 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