Archived Forum Post

Index of archived forum posts

Question:

Failed to setup passive data socket error?

Oct 18 '12 at 18:55

I’ve built an FTP application using your toolkit and it tests fine on from various FTP servers and to various FTP server. I encountered a problem today when using TLS security. The connection works fine but when trying to upload files I receive the error "timeout waiting for connect to complete" and "failed to setup passive data socket". I’ve also set the PassiveUseHostAddr property = true with the same result.


Answer

The FTP protocol is such that data transfers (including directory listings) happen over a separate data connection. Each transfer happens on it's own connection. The establishment of the data connection is often blocked by a firewall, which could be on the client-side, the server-side, or both. Usually, the simplest fix is to switch to non-passive mode (also called Active or Port mode). Do this by setting the ftp.Passive property = false (0).

See this Chilkat blog post for Active vs. Passive Mode Explained.

If that doesn't solve it, there are potentially many other settings that can play a role in FTP data connection establishment. The best guide for beginning to understand the settings is located here:

Determining FTP Data Connection Settings


Answer

One follow-up question. The upload works fine when not using TLS security. I only get this error with TLS enabled. Will your suggested fix still be applicable since it works in passive mode without security?


Answer

See the information at these web pages. Especially firewalls...

The File Transfer Protocol (FTP) and Your Firewall / Network Address Translation (NAT) Router / Load-Balancing Router

Wikipedia: File Transfer Protocol

Active FTP vs. Passive FTP, a Definitive Explanation

The FTP2.DetermineSettings Method

Issue when an FTP Server is behind a NAT Router

FTP Blockers - TCP/IP Port Filtering and Anti-Virus

Deep Inspection Firewalls and Passive FTP (also known as Stateful Inspection Firewalls)

Issue with Checkpoint Firewall and FTP

Active vs. Passive FTP

Port Range for Passive FTP?

WSAEWOULDBLOCK when trying to establish FTP2 Data Connection in Passive Mode with SSL/TLS

Running out of Ports for FTP Data Transfers