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.

Error after downloading lots of files

See original GitHub issue

I have a timer that runs every 100ms. It goes through a list of known remote file paths on the FTP server and attempts to download them to the local machine.

The timer has locks to ensure that only 3 requests are active at any one time (every time a download finishes it releases another slot to the pool).

This works well for about 20 seconds before get() errors out with

Unable to make data connection

Here is a reduced example of what is happening

function ftpController() {

    this.conn = new ftpClient();
}

ftpController.prototype.downloadFile = function(remotePath, cb) {

    cb = cb || function() {};

    localPath = mods.folderPath + remotePath;

    ftp.conn.get(remotePath, function(err, stream) {

        if (err) {

            debug('** Error downloading ' + remotePath, err);

            cb(false);
        } else {

            stream.pipe(fs.createWriteStream(localPath));
            cb(true);
        }
    });
};

// Stripped code example
ftp.downloadFile('/test/test1.txt', releaseAnotherDownload);
ftp.downloadFile('/test/test2.txt', releaseAnotherDownload);
ftp.downloadFile('/test/test3.txt', releaseAnotherDownload);

Should I be creating a new connection for each download rather than trying to use the same, is my FTP server throttling me because I’m not making a new connection for each file?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:2
  • Comments:14

github_iconTop GitHub Comments

4reactions
phillipgreeniicommented, Jul 28, 2015

I was just bitten by this as well. It looks like the problem is in connection.js with self._pasvSocket = socket;. It replaces _pasvSocket each time. So for example, GET 1 sets _pasvSocket, GET 2 overrides _pasvSocket, then GET 1 completes, which clears _pasvSocket, so GET 2 fails with Unable to make data connection. In my testing, it was always the third GET that was causing the problem, but I would guess that it depends on the timing for each GET.

1reaction
rastalammcommented, Oct 25, 2018

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix file download errors - Google Chrome Help
If you get an error message on Chrome when you try to download apps, themes, extensions, or other files, try these fixes.
Read more >
6 Ways to Fix the “Download Failed Network Error” on Chrome
6 Ways to Fix the “Download Failed Network Error” on Chrome · 1. Check Your Internet Speed and Connection · 2. Modify Your...
Read more >
Can't Download Anything on a Windows 10 Computer [Solved]
Fix 1: Check If Many Files Are Being Downloaded; Fix 2: Change Internet Option Settings; Fix 3: Clear Your Browser's Cache; Fix 4:...
Read more >
How to fix unable to run or other errors with a downloaded file
If you cannot open a file that you downloaded, or cannot run a downloaded executable file, the following steps may help you fix...
Read more >
Folder copy error message when downloading a file that is ...
Describes a folder copy error that occurs because a security change in Windows XP SP2 or later affects the WebDAV redirector.
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