cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Problems with curl timeout setting

From: Ralph Seward <rj_seward_at_hotmail.com>
Date: Thu, 27 Jan 2011 15:17:36 +0000

Re: Problems with curl timeout setting
First, apologies for putting my comments at the top of this discussion - I was just not sure where I should insert it. But, if your timeout problem is PHP related you can work around it by inserting a simple PHP statement at the beginning of your code:

set_time_limit(0);
which effectively removes the time limit imposed by the server's php.ini. (Note that this will not work if PHP is running in safe mode.) See http://php.net/manual/en/function.set-time-limit.php for details on this directive.
Also, at the end of your script you should set the time limit back to something sane, like set_time_limit(30);
RJSeward

> 1. Re: Problems with curl timeout setting (Daniel Stenberg)
> 2. Re: Problems with curl timeout setting (127546_at_sms13.de)
> 3. Re: Problems with curl timeout setting (Daniel Stenberg)
> 4. Re: Problems with curl timeout setting (127546_at_sms13.de)
> 5. Re: Problems with curl timeout setting (Daniel Stenberg)
> 6. Re: Problems with curl timeout setting (127546_at_sms13.de)
> 7. Re: Problems with curl timeout setting (Daniel Stenberg)
> 8. Re: Problems with curl timeout setting (127546_at_sms13.de)
> 9. Re: Problems with curl timeout setting (Daniel Stenberg)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 26 Jan 2011 14:40:49 +0100 (CET)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <alpine.DEB.2.00.1101261439010.26696_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Wed, 26 Jan 2011, 127546_at_sms13.de wrote:
>
> >> It is also relevant what resolver you're using, as if you use the stock
> >> *nix resolver, it has a full-second resolution in the time-outs.
> >
> > By resolver do you mean dns? I believe I do not use any resolver because we
> > connect only using IP?
>
> Ah, OK, then the resolver is not the key...
>
> > Also we think that we found something relevant. We think that the servers we
> > connect to which cause these timeout problems are not the real well known
> > http servers like apache or nginx. We are pretty sure that the server is
> > some self written perl code. Is this possible that this server does not
> > return some important headers which causes this timeout problems? For
> > example, we connect to server on port 80 and it does not return anything,
> > (no content whatsoever for 5 seconds, including no headers), can this affect
> > timeouts working?? We think it can, we will try to test it
>
> I don't see why it would. libcurl is made to obey the timeout no matter what
> it is doing, and a funny server shouldn't change that. But obviously there's a
> problem somewhere...
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 26 Jan 2011 14:49:54 +0100
> From: 127546_at_sms13.de
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <1707301092.20110126144954_at_sms13.de>
> Content-Type: text/plain; charset=iso-8859-15
>
> Hello Daniel,
>
>
> >> Also we think that we found something relevant. We think that the servers we
> >> connect to which cause these timeout problems are not the real well known
> >> http servers like apache or nginx. We are pretty sure that the server is
> >> some self written perl code. Is this possible that this server does not
> >> return some important headers which causes this timeout problems? For
> >> example, we connect to server on port 80 and it does not return anything,
> >> (no content whatsoever for 5 seconds, including no headers), can this affect
> >> timeouts working?? We think it can, we will try to test it
>
> > I don't see why it would. libcurl is made to obey the timeout no matter what
> > it is doing, and a funny server shouldn't change that. But obviously there's a
> > problem somewhere...
>
>
> what do you think we should do then? Try this from C or command line outside of PHP? Can a php be
> problem here? I very much doubt it because it still uses C code. Nobody else is having such
> problems? Clearly something is wrong here
>
> --
> Best regards,
> 127546 mailto:127546_at_sms13.de
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 26 Jan 2011 17:00:27 +0100 (CET)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <alpine.DEB.2.00.1101261657490.26287_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
>
> On Wed, 26 Jan 2011, 127546_at_sms13.de wrote:
>
> > what do you think we should do then? Try this from C or command line outside
> > of PHP?
>
> Yes. We need to narrow down things.
>
> I tried this:
>
> [shell 1]
> $ nc -p 9999 -l
>
> [shell 2]
> $ curl localhost:9999 -m3
>
> ... and it timed out after exactly 3000 milliseconds.
>
> > Can a php be problem here?
>
> I don't think so.
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 26 Jan 2011 22:18:32 +0100
> From: 127546_at_sms13.de
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <322614651.20110126221832_at_sms13.de>
> Content-Type: text/plain; charset=iso-8859-15
>
> Hello Daniel,
>
> Wednesday, January 26, 2011, 5:00:27 PM, you wrote:
>
> > On Wed, 26 Jan 2011, 127546_at_sms13.de wrote:
>
> >> what do you think we should do then? Try this from C or command line outside
> >> of PHP?
>
> > Yes. We need to narrow down things.
>
> > I tried this:
>
> > [shell 1]
> > $ nc -p 9999 -l
>
> > [shell 2]
> > $ curl localhost:9999 -m3
>
> > ... and it timed out after exactly 3000 milliseconds.
>
>
> I did some more research here, first of all I cannot reproduce my problem on command line because
> command line does not support milliseconds, and it seems the issue arises only when you specify
> milliseconds!!!
>
> when we changed CURL options in php into seconds the issue does not arise!! The bug is clearly in
> the millisecond settings but we need milliseconds. I can see many people on google complaining abotu
> this option not working correctly. I am desperate here as you see, I am willing to pay for someone
> to fix this for me!!
>
> Also I find this post of yours: http://comments.gmane.org/gmane.comp.web.curl.library/29210
> where you say
>
> "CURLOPT_CONNECTTIMEOUT does not really work for the multi interface in any
> released libcurl version. We're working on making sure it works correctly
> for the next release."
>
> ps. we found similar problem with
> curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT_MS,300);
>
> we set 500ms but the error message is Connection timed out after 1001 milliseconds
>
> as I stated earlier I am willing to pay to get this fixed
>
>
>
> --
> Best regards,
> 127546 mailto:127546_at_sms13.de
>
>
>
> ------------------------------
>
> Message: 5
> Date: Thu, 27 Jan 2011 00:09:46 +0100 (CET)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <alpine.DEB.2.00.1101270001010.14066_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
>
> On Wed, 26 Jan 2011, 127546_at_sms13.de wrote:
>
> > I did some more research here, first of all I cannot reproduce my problem on
> > command line because command line does not support milliseconds, and it
> > seems the issue arises only when you specify milliseconds!!!
>
> I don't believe you. I'm convinced the reason is something else.
>
> > when we changed CURL options in php into seconds the issue does not arise!!
> > The bug is clearly in the millisecond settings but we need milliseconds.
>
> There's only one place in the libcurl code that differs between seconds and
> milliseconds, and that is the code that receives the options. If you set
> seconds, the code will multiply the number with 1000 and store that internally
> as milliseconds. Everything internally is done using the single timeout value
> that is counted in milliseconds.
>
> > I can see many people on google complaining abotu this option not working
> > correctly.
>
> You can find anything searching with Google. That's not an argument that means
> anything.
>
> And even if others have had similar or even the exact same problem, that's not
> helping here either.
>
> > I am desperate here as you see, I am willing to pay for someone to fix this
> > for me!!
>
> I'm willing to work on fixing the bug for free, but I'm not going to run any
> PHP and I doubt you need PHP to get it. I'd urge you to write up a C program
> that uses libcurl and that shows the problem happening.
>
> > "CURLOPT_CONNECTTIMEOUT does not really work for the multi interface in any
> > released libcurl version. We're working on making sure it works correctly
> > for the next release."
>
> The key words there being "in any released libcurl version" and then you
> should check the date I wrote that and compare with release dates and you'll
> see that the statement is no longer true. (Which is kind of related to my
> comment that you can find everything.)
>
> But this made me curious. Are you saying you're using the multi interface?
>
> > as I stated earlier I am willing to pay to get this fixed
>
> I don't have time or opportunity to take on any new projects at the moment so
> that someone you can pay will not be me.
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> Message: 6
> Date: Thu, 27 Jan 2011 00:17:04 +0100
> From: 127546_at_sms13.de
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <86494106.20110127001704_at_sms13.de>
> Content-Type: text/plain; charset=iso-8859-15
>
> Hello Daniel,
>
> Thursday, January 27, 2011, 12:09:46 AM, you wrote:
>
> > On Wed, 26 Jan 2011, 127546_at_sms13.de wrote:
>
> >> I did some more research here, first of all I cannot reproduce my problem on
> >> command line because command line does not support milliseconds, and it
> >> seems the issue arises only when you specify milliseconds!!!
>
> > I don't believe you. I'm convinced the reason is something else.
>
> I wanted to prove to you, but command line tool does not support ms :)
>
> >> I am desperate here as you see, I am willing to pay for someone to fix this
> >> for me!!
>
> > I'm willing to work on fixing the bug for free, but I'm not going to run any
> > PHP and I doubt you need PHP to get it. I'd urge you to write up a C program
> > that uses libcurl and that shows the problem happening.
>
> we have no time to write this in C, but seems we have no choice :(
>
>
> > But this made me curious. Are you saying you're using the multi interface?
>
> yes, does it change anything?
>
>
>
>
>
> --
> Best regards,
> 127546 mailto:127546_at_sms13.de
>
>
>
> ------------------------------
>
> Message: 7
> Date: Thu, 27 Jan 2011 00:19:19 +0100 (CET)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <alpine.DEB.2.00.1101270018270.14066_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Thu, 27 Jan 2011, 127546_at_sms13.de wrote:
>
> >> But this made me curious. Are you saying you're using the multi interface?
> >
> > yes, does it change anything?
>
> Yes it does. A lot. The command line tool doesn't use it for example...
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> Message: 8
> Date: Thu, 27 Jan 2011 00:24:11 +0100
> From: 127546_at_sms13.de
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <914736710.20110127002411_at_sms13.de>
> Content-Type: text/plain; charset=iso-8859-15
>
> Hello Daniel,
>
> Thursday, January 27, 2011, 12:19:19 AM, you wrote:
>
> > On Thu, 27 Jan 2011, 127546_at_sms13.de wrote:
>
> >>> But this made me curious. Are you saying you're using the multi interface?
> >>
> >> yes, does it change anything?
>
> > Yes it does. A lot. The command line tool doesn't use it for example...
>
>
> okay, what do you propose then? C code using multi?
>
> --
> Best regards,
> 127546 mailto:127546_at_sms13.de
>
>
>
> ------------------------------
>
> Message: 9
> Date: Thu, 27 Jan 2011 08:43:19 +0100 (CET)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: curl with PHP <curl-and-php_at_cool.haxx.se>
> Subject: Re: Problems with curl timeout setting
> Message-ID: <alpine.DEB.2.00.1101270833510.8016_at_tvnag.unkk.fr>
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Thu, 27 Jan 2011, 127546_at_sms13.de wrote:
>
> > okay, what do you propose then? C code using multi?
>
> Yes. We can probably just edit one of the examples (like this:
> http://curl.haxx.se/libcurl/c/multi-single.html) with the added timeout values
> and use against 'nc' to see that it times out accurately.
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> _______________________________________________
> curl-and-php mailing list
> curl-and-php_at_cool.haxx.se
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
> End of curl-and-php Digest, Vol 65, Issue 6
> *******************************************
                                               

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2011-01-27