superafroman / node-torrent

Bittorrent client for node.js.
428 stars 100 forks source link

EMFILE issues (too many files open) on Mac OS #27

Open luisnomad opened 9 years ago

luisnomad commented 9 years ago

[2015-10-05 13:35:15.305] [WARN] tracker.js - announce error from udp://tracker.istole.it:80/announce: bind EMFILE [2015-10-05 13:35:15.305] [WARN] tracker.js - retry announce 'started' in 5s

It looks like it is a OS specific issue, and people seem to suggest the same solution: http://superuser.com/questions/433746/is-there-a-fix-for-the-too-many-open-files-in-system-error-on-os-x-10-7-1

But still it does not work for everyone -me included, I still get the error-.

I have tried using graceful-js, but no luck.

Additionally, whenever I am running this sample code, my laptop becomes extremely hot and battery drains fast:

var Client = require('node-torrent');
var client = new Client({logLevel: 'DEBUG'});
var torrent = client.addTorrent('a.torrent');

// when the torrent completes, move it's files to another area
torrent.on('complete', function() {
    console.log('complete!');
    torrent.files.forEach(function(file) {
        var newPath = '/new/path/' + file.path;
        fs.rename(file.path, newPath);
        // while still seeding need to make sure file.path points to the right place
        file.path = newPath;
    });
});

Has anyone used this library successfully on Mac OS? Is there a solution for the EMFILE error?

reezpatel commented 4 years ago

ulimit -n 1000 I think this will solve your problem. Run it before starting this.