question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Curl request never finish / return, timeout does not work

See original GitHub issue

With 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:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tomrfcommented, Feb 28, 2017

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!

0reactions
JCMaiscommented, Feb 28, 2017

Also note ‘0 out of -1 bytes received’ – is the operation expecting -1 bytes? Seems weird.

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?

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found