Skip to content

Bug: Control connection times out despite active data channel #387

Description

@JeredArc

Bug Description

The FTP server (ftp-srv v4.6.3) terminates the control connection after the idle timeout period even when there is an active data transfer in progress. This causes uploads to fail for big files / slow transfer rates.

My particular case

  • (Running on Windows 11 Pro, node v22.14.0)
  • I created FtpSrv with timeout: 600000 (10 minutes) in the options
  • I use it as upload interface into a database, so I provide a custom fs object with a write function returning a writeStream where I can also log the receiving of chunks
  • I set up ftp command logging (listen to connection.commandSocket.on('data', ...), intercept connection.commandSocket.write)
  • I have a device uploading files larger than 600 KB at approx 1 KB/s, meaning it takes longer than 10 minutes
  • Exactly after 10 minutes the connection is closed, while upload on the data channel would still be going

The log

2025-04-04T13:25:54.189Z New connection from 192.168.223.30
2025-04-04T13:25:54.191Z [192.168.223.30] Server: 220 Ready
2025-04-04T13:25:54.288Z [192.168.223.30] Client: user username
2025-04-04T13:25:54.289Z [192.168.223.30] Server: 331 Username okay, awaiting password
2025-04-04T13:25:55.287Z [192.168.223.30] Client: pass password
2025-04-04T13:25:55.289Z [192.168.223.30] Server: 230 User logged in, proceed
2025-04-04T13:25:56.287Z [192.168.223.30] Client: pasv
2025-04-04T13:25:56.290Z [192.168.223.30] Server: 227 PASV OK (192,168,223,10,195,80)
2025-04-04T13:25:57.308Z [192.168.223.30] Client: cwd /
2025-04-04T13:25:57.309Z [192.168.223.30] Server: 250 "/"
2025-04-04T13:25:58.498Z [192.168.223.30] Client: stor filename.xml
2025-04-04T13:25:58.563Z [192.168.223.30] writeStream pipe event triggered for filename.xml
2025-04-04T13:25:58.563Z [192.168.223.30] Server: 150 File status okay; about to open data connection
2025-04-04T13:25:59.509Z [192.168.223.30] writeStream data chunk received for filename.xml (100 bytes)
2025-04-04T13:25:59.509Z [192.168.223.30] writeStream data chunk received for filename.xml: 100 bytes (total: 100 bytes)
2025-04-04T13:25:59.712Z [192.168.223.30] writeStream data chunk received for filename.xml: 200 bytes (total: 300 bytes)
2025-04-04T13:25:59.919Z [192.168.223.30] writeStream data chunk received for filename.xml: 200 bytes (total: 500 bytes)
2025-04-04T13:26:00.126Z [192.168.223.30] writeStream data chunk received for filename.xml: 200 bytes (total: 700 bytes)
2025-04-04T13:26:00.334Z [192.168.223.30] writeStream data chunk received for filename.xml: 273 bytes (total: 973 bytes)
2025-04-04T13:26:00.542Z [192.168.223.30] writeStream data chunk received for filename.xml: 264 bytes (total: 1237 bytes)
2025-04-04T13:26:00.750Z [192.168.223.30] writeStream data chunk received for filename.xml: 264 bytes (total: 1501 bytes)
...
2025-04-04T13:35:57.803Z [192.168.223.30] writeStream data chunk received for filename.xml: 172 bytes (total: 629729 bytes)
2025-04-04T13:35:58.010Z [192.168.223.30] writeStream data chunk received for filename.xml: 200 bytes (total: 629929 bytes)
2025-04-04T13:35:58.217Z [192.168.223.30] writeStream data chunk received for filename.xml: 172 bytes (total: 630101 bytes)
2025-04-04T13:35:58.424Z [192.168.223.30] writeStream data chunk received for filename.xml: 200 bytes (total: 630301 bytes)
2025-04-04T13:35:58.551Z [192.168.223.30] Server: 421 Closing connection
2025-04-04T13:35:58.553Z [192.168.223.30] Client disconnected

The connection is closed (421 Closing connection) exactly 10 minutes after the last control command (150 File status okay). The upload obviously fails.

A quick workaround (which I’ll probably use for now) is to send NOOP commands while data is received, but this should be handled by the server automatically.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions