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.

451-Error during read from data connection

See original GitHub issue

Describe the bug There is a repeatable error during file upload in case of specific file size (around 45k, one specific file size is 45017 bytes) and network speed (fast). If the file is smaller or larger, the error disappears (file content does not matter). If the network speed is slower, error also disappears. Reproduces with minimal code (new Client + access + uploadFrom), but as is location-specific, is probably very little use. Typically 32k gets uploaded before error appears (but sometimes less)

Possible racing condition?

Problem does NOT depend on:

  • file content
  • file name

Ubuntu 18.04 Node v12.22.1 basic-ftp 4.6.6

Would be happy to provide any additional data if requested.

Exception thrown:

FTPError: 451-Error during read from data connection
451-Transfer aborted
451 0.058 seconds (measured here), 0.54 Mbytes per second
    at FTPContext._onControlSocketData (node_modules/basic-ftp/dist/FtpContext.js:282:39)
    at TLSSocket.<anonymous> (node_modules/basic-ftp/dist/FtpContext.js:123:44)
    at TLSSocket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:268:11)
    at TLSSocket.Readable.push (_stream_readable.js:213:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) {

Verbose log:

Connected to x.x.x.x:21 (No encryption)
< 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 9 of 500 allowed.
220-Local time is now 07:20. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 30 minutes of inactivity.

> AUTH TLS
< 234 AUTH TLS OK.

Control socket is using: TLSv1.3
Login security: TLSv1.3
> USER x
< 331 User x OK. Password required

> PASS ###
< 230-User global permissions: DOWNLOAD (yes) UPLOAD (yes) [NEW (yes) RESUME (yes) OVERWRITE (yes) VIRUSES(no)] RENAME (yes) DELETE (yes) CHMOD (yes) MKDIR (yes) RMDIR (yes) CHDIR (yes) LIST (yes)

< 230 OK. Current restricted directory is /

> FEAT
< 211-Extensions supported:
 UTF8
 EPRT
 IDLE
 MDTM
 SIZE
 MFMT
 REST STREAM
 MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
 MLSD
 PRET
 AUTH TLS
 PBSZ
 PROT
 TVFS
 ESTA
 PASV
 EPSV
 SPSV
 ESTP

< 211 End.

> TYPE I
< 200 TYPE is now 8-bit binary

> STRU F
< 200 F OK

> OPTS UTF8 ON
< 200 Always in UTF8 mode

> OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;
< 200  MLST OPTS type;size;sizd;modify;UNIX.mode;UNIX.uid;UNIX.gid;unique;

> PBSZ 0
< 200 PBSZ=0

> PROT P
< 200 Data protection level set to "private"

> CWD /gfx/300x300
< 250 OK. Current directory is /gfx/300x300

Trying to find optimal transfer mode...
> EPSV
< 500 Unknown command

Transfer mode failed: "500 Unknown command", will try next.
> PASV
< 227 Entering Passive Mode (x,x,x,x,240,105)

Optimal transfer mode found.
> STOR 6u711d1f5yd4m3nu7g515k3i34bvon168731.png.part
< 150 Accepted data connection

Uploading to x.x.x.x:61545 (TLSv1.3)
< 451-Error during read from data connection

< 451-Transfer aborted

< 451 0.070 seconds (measured here), 459.00 Kbytes per second

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
patrickjuchlicommented, Jun 28, 2022

Sorry, haven’t been aware of this issue for a long time and too busy to do anything here. I wanted to have a look first but if this does help all of you then let’s just do this. Yes, will accept PR. Thanks all, and sorry again.

2reactions
PRR24commented, Oct 26, 2021

Tracked the issue down to transfer.ts

source.pipe(dataSocket).once("finish", () => {
    dataSocket.destroy() // Explicitly close/destroy the socket to signal the end.
    resolver.onDataDone(task)
})

It seems that the dataSocket gets destroyed before all the data is actually sent out by the dataSocket.

Should’t it be

source.pipe(dataSocket).once("end", () => {

instead?

Read more comments on GitHub >

github_iconTop Results From Across the Web

451 FTP response code - SolarWinds Success Center
It is usually sent in response to the server encountering an unexpected local error when processing data it is transferring or receiving.
Read more >
PQ97801: FTP REPLY CODE '451 TRANSFER ABORTED - IBM
A FTP client may get a FTP reply '451 transfer aborted: file error' on a large file transfer when using filetype=JES and.
Read more >
How To Fix or Bypass Error 451: Unavailable Due to Legal ...
In a nutshell, this error message indicates that the website owner or your local government/authority has blocked access to the website in order...
Read more >
451 - FileZilla Forums
Error codes starting with 4 indicate a temporary error. Just retry at a later time. Unless of course the server is broken and...
Read more >
451 Failure writing to local file - 2BrightSparks Help and Support
This error is returned from an FTP server when it cannot store a file that is being sent to it (from SyncBackPro, SyncBackSE...
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