Curl request never finish / return, timeout does not work
See original GitHub issueWith the following example, curl never returns anything, and never times out.
Using curl(1) from the command line with -L -v shows a 301 redirect to a slow https site, but data is returned with HTTP 200 after about 10 seconds.
With node-libcurl, no ‘end’ or ‘error’ event is ever fired, and the request never times out even though TIMEOUT is set to three seconds.
Any ideas?
var Curl = require('node-libcurl').Curl;
function curlUrl(url, callback) {
var curl = new Curl();
curl.setOpt('URL', url);
curl.setOpt('FOLLOWLOCATION', true);
curl.setOpt('TIMEOUT', 3);
curl.on('end', function(statusCode, body, headers) {
this.close();
callback(body, statusCode);
});
curl.on('error', function (err, code) {
curl.close.bind(curl);
callback(null, code);
});
curl.perform();
}
curlUrl('http://arrow.no', function(results, errorCode) {
console.log(results, errorCode);
});
Node version: v6.9.4 node-libcurl@1.1.0
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Does curl have a timeout? - Unix & Linux Stack Exchange
Yes. Timeout parameters. curl has two options: --connect-timeout and --max-time . Quoting from the manpage: --connect-timeout <seconds> ...
Read more >How to set a timeout for a Curl request? - ReqBin
Curl sends requests works over a network connection. The first step in getting a resource from a server is to connect to that...
Read more >Timeouts - Everything curl
When the set time has elapsed, curl will exit no matter what is going on at that moment—including if it is transferring data....
Read more >Timeout issue in CURL command in shell script - Stack Overflow
I am having a curl command as follows curl --max-time 900 --location --request GET "https://XXXXXX/YYYYY?
Read more >Curl error: 28 (OPERATION_TIMEOUTED) Fixed! - Bobcares
Curl error: 28 (OPERATION_TIMEOUTED) happens when curl request from the website takes too much time to complete. The fix involves tweaking ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I upgrade curl/libcurl to v7.53.1 and TIMEOUT now works as expected. Sadly curl 7.29 comes with the latest release of CentOS (maybe RedHat and Fedora too?). Maybe add a warning on install or use about older versions of libcurl? I dunno.
Thanks a bunch for helping me debug this!
This does look weird, but your libcurl version is more than 4 years old, can you install a newer one to check if the issue is fixed?