Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libcurl stuck in POLLIN timeouts

Tags:

php

curl

A libcurl in my php code seems to be stuck indefinitely in a poll call. When I did an strace to the process id,

[user@server ~]$ sudo strace -p 19559
Process 19559 attached - interrupt to quit
poll([{fd=7, events=POLLIN}], 1, 1000)  = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0)     = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 1000)  = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0)     = 0 (Timeout) 
poll([{fd=7, events=POLLIN}], 1, 1000)  = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0)     = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 1000)  = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0)     = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 1000)  = 0 (Timeout)

This goes on indefinitely. The fd 7 is shown in /proc/19559/fd as

lrwx------ 1 root root 64 Sep 19 19:44 7 -> socket:[335178801]

Can someone tell me why this is happening. What can I do to make libcurl exit when it timesout

like image 364
Aks Avatar asked Sep 26 '12 06:09

Aks


People also ask

Does curl have a time-out?

Further, most operations in curl have no time-out by default! Tell curl with -m / --max-time the maximum time, in seconds, that you allow the command line to spend before curl exits with a timeout error code (28). When the set time has elapsed, curl will exit no matter what is going on at that moment—including if it is transferring data.

How do I fix curl timeout error 28?

Tell curl with -m / --max-time the maximum time, in seconds, that you allow the command line to spend before curl exits with a timeout error code (28). When the set time has elapsed, curl will exit no matter what is going on at that moment—including if it is transferring data. It really is the maximum time allowed.

How do I tell curl to stop a transfer?

As an alternative to a fixed time-out, you can tell curl to abandon the transfer if it gets below a certain speed and stays below that threshold for a specific period of time. For example, if a transfer speed goes below 1000 bytes per second during 15 seconds, stop it: curl enables TCP keep-alive by default.

What does the function Curle_OK return?

Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value or a value that when converted to milliseconds is too large.


1 Answers

curl_setopt option CURLOPT_CONNECTTIMEOUT if set to nonzero value will render curl to fail on timeout.

like image 135
J0HN Avatar answered Sep 23 '22 00:09

J0HN