Skip to content

FTPS connection silently dies after idle timeout — status still shows "connected", no auto-reconnect (FTP/FTPS missing keepalive & socket event listeners) #8

Description

@deepdfhy

Environment

  • Extension version: 1.2.21

  • Protocol: FTPS (explicit TLS, port 21)

  • OS: Windows 11

  • Editor: Trae (VSCode-based, vscode engine ^1.75)

Steps to Reproduce

  1. Connect to an FTPS server (protocol: "ftps", port 21) via .vscode/sftp.json.

  2. Upload/download works fine right after connecting.

  3. Leave the connection idle for a few minutes to tens of minutes.

  4. Try to upload or download again.

Actual Behavior

  • All uploads/downloads fail, but the status bar / explorer still shows the connection as "connected".

  • The only workaround is manually disconnecting and reconnecting.

  • Plain FTP and SFTP do NOT have this problem — both survive idle periods correctly.

Expected Behavior

  • Either the idle control connection is kept alive (NOOP), or the dead connection is detected and auto-reconnected (the stackerftp.autoReconnect: true setting already exists but never fires for FTP/FTPS).

Root Cause Analysis (from bundled dist/extension.js 1.2.21)

Comparing the two connection classes:

  1. SFTPConnection attaches listeners to the ssh2 client (close / end / error), sets _connected = false and emits "disconnected" on drop — which triggers ConnectionManager.scheduleReconnect() (autoReconnect defaults to true). That's why SFTP works.

  2. FTPConnection sets _connected = true in connect() and never attaches any listener to the control socket (client.ftp.socket), and **never emits "disconnected"

Activity

  1. yasinkuyu commented on Oct 4, 2026

    @yasinkuyu
    Owner

    Thanks a lot for the detailed report and the root cause analysis — it was spot on. 🙏

    Fixed in 01f6b05:

    • FTPConnection now watches the control socket (close / end / error). A connection closed by the server is no longer shown as "connected", and it emits disconnected, so autoReconnect now works for FTP/FTPS as well.
    • While idle, a NOOP keepalive is sent (uses the keepalive setting, default 30 s, 0 disables it).
    • The pooled transfer connection that was silently reused after the idle timeout is now detected as dead and replaced. Transfers reconnect on demand, and a transfer interrupted by a dropped connection is retried once automatically.
    • The FTP operation timeout is at least 30 s again (1.3.0 had reduced it to the 10 s connTimeout default).

    This will ship in 1.3.1. If you still see the problem after updating, please reopen this issue with the log output (SFTP: View Logs).

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions