Question:
I'm trying to use active FTP with Chilkat. Here is the Output from a working FTP-Client (FlashFXP):
SYST
215 UNIX Type: L8
REST 100
350 Restarting at 100. But we're in ASCII mode
REST 0
350 Restarting at 0
PWD
257 "/" is your current location
PROT P
200 Data protection level set to "private"
Listening on PORT: 54131, Waiting for connection.
PORT 192,110,130,33,211,115
500 I won't open a connection to 192.110.130.33 (only to 80.130.210.228)
PORT 80,130,210,228,211,115
200 PORT command successful
LIST -al
150 Connecting to port 54131
TLSv1.2 negotiation successful...
TLSv1.2 encrypted session using cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)
226-Options: -a -l
226 12 matches total
List Complete: 974 bytes in 0,37 seconds (1,0 KB/s)
The interesting part is:
Listening on PORT: 54131, Waiting for connection.
PORT 192,110,130,33,211,115
500 I won't open a connection to 192.110.130.33 (only to 80.130.210.228)
PORT 80,130,210,228,211,115
200 PORT command successful
the client binds a port on my internal ip. Then its using that port with my external ip (my router is forwarding all requests to my internal ip). all is working fine that way.
now to Chilkat FTP2: i cannot get it working with active mode :)
snipped from my code:
put_Passive(false);
put_Hostname(...);
put_Username(...);
put_Password(...);
put_Port(990);
put_HeartbeatMs(200);
put_SendBufferSize(4096);
put_AuthTls(true);
put_Ssl(false);
put_ForcePortIpAddress("80.130.210.228");
// explicit ssl !
put_AutoFix(false);
Connect();
GetDirCount();
but GetDirCount() is failing:
ChilkatLog:
GetDirCount:
DllDate: Mar 14 2016
ChilkatVersion: 9.5.0.56
UnlockPrefix: INGENIFTP
Username: PC-MARCO:Marco
Architecture: Little Endian; 32-bit
Language: Visual C++ 10.0 (32-bit)
VerboseLogging: 0
listPattern: *
fetchDirListing:
pattern: *
supportsMLSD: 1
fetchDirListing2:
pbsz_protp:
simpleCommand:
sendCommand:
sendingCommand: PBSZ 0
--sendCommand
readCommandResponse:
replyLineQP: 200 PBSZ=3D0
--readCommandResponse
--simpleCommand
simpleCommand:
sendCommand:
sendingCommand: PROT P
--sendCommand
readCommandResponse:
replyLineQP: 200 Data protection level set to "private"
--readCommandResponse
--simpleCommand
--pbsz_protp
setupDataConnection:
active transfer mode
setupActiveDataSocket:
Using ephemeral port range for Active data connection.
SocketError: WSAEADDRNOTAVAIL Cannot assign requested address.
Socket bind failed.
Failed to bind socket.
--setupActiveDataSocket
Failed to setup active data socket.
Try using passive mode instead.
--setupDataConnection
Failed to setup data connection for dir listing.
readRepliesAfterFailedDataConn:
readCommandResponse:
idleTimeoutMs: 1000
tlsReadIncoming: Socket operation timeout.
Failed to receive more TLS applicaton data.
Failed to read FTP control channel reply.
readFtpReply: Socket operation timeout.
--readCommandResponse
--readRepliesAfterFailedDataConn
--fetchDirListing2
--fetchDirListing
N: -1
Failed.
--GetDirCount
--ChilkatLog
i think he tries to bind the port to my external ip. but this wont work. here a log without put_ForcePortIpAddress();
ChilkatLog:
GetDirCount:
DllDate: Mar 14 2016
ChilkatVersion: 9.5.0.56
UnlockPrefix: INGENIFTP
Username: PC-MARCO:Marco
Architecture: Little Endian; 32-bit
Language: Visual C++ 10.0 (32-bit)
VerboseLogging: 0
listPattern: *
fetchDirListing:
pattern: *
supportsMLSD: 1
fetchDirListing2:
pbsz_protp:
simpleCommand:
sendCommand:
sendingCommand: PBSZ 0
--sendCommand
readCommandResponse:
replyLineQP: 200 PBSZ=3D0
--readCommandResponse
--simpleCommand
simpleCommand:
sendCommand:
sendingCommand: PROT P
--sendCommand
readCommandResponse:
replyLineQP: 200 Data protection level set to "private"
--readCommandResponse
--simpleCommand
--pbsz_protp
setupDataConnection:
active transfer mode
setupActiveDataSocket:
Using ephemeral port range for Active data connection.
dataPort: 54517
portIpAddress: 192.110.130.33
MyIPv4: 192,110,130,33,212,245
sendCommand:
sendingCommand: PORT 192,110,130,33,212,245
--sendCommand
readCommandResponse:
replyLineQP: 500 I won't open a connection to 192.110.130.33 (only to 80.130.210.228)
--readCommandResponse
--setupActiveDataSocket
Failed to setup active data socket.
Try using passive mode instead.
--setupDataConnection
Failed to setup data connection for dir listing.
readRepliesAfterFailedDataConn:
readCommandResponse:
idleTimeoutMs: 1000
tlsReadIncoming: Socket operation timeout.
Failed to receive more TLS applicaton data.
Failed to read FTP control channel reply.
readFtpReply: Socket operation timeout.
--readCommandResponse
--readRepliesAfterFailedDataConn
--fetchDirListing2
--fetchDirListing
N: -1
Failed.
--GetDirCount
--ChilkatLog
port binding is working, but the PORT command has to use my external ip
please help. did i missed something?
i already tried connecting without put_ForcePortIpAddress()
. after connect i used put_ForcePortIpAddress()
, but this wont work either.
Thanks in advance for any help
marco
Thanks Marco,
I'll work to get this fixed today. I'll post a pre-release download link later (could be much later today) when it's ready..
Here's the new build:
32-bit Download: http://www.chilkatsoft.com/download/preRelease/chilkat-9.5.0-x86-vc10.zip
64-bit Download: http://www.chilkatsoft.com/download/preRelease/chilkat-9.5.0-x86_64-vc10.zip
The changes are:
Thanks for your reply, chilkat!
works like a charm! but i have to get my external ip from some other services like whatsmyip.com cause i'm on an dialup line with dynamic ip-addresses. but thats ok, i will write my own service for this.
nice feature, i can't test it :)
that's cool. it's using my server-address for the port command. if failed it's using my external ip. i don't know if it makes sense to use the server ip for the PORT command!? Here some log (80.130.210.7 is my current external IP, 192.110.130.33 my internal):
setupDataConnection: active transfer mode setupActiveDataSocket: Using ephemeral port range for Active data connection. dataPort: 50175 portIpAddress: [serverIP] MyIPv4: [serverIP],195,255 sendCommand: sendingCommand: PORT [serverIP],195,255 --sendCommand readCommandResponse: replyLineQP: 500 I won't open a connection to [serverIP] (only to 80.130.210.7) --readCommandResponse Retrying PORT command. sendCommand: sendingCommand: PORT 80.130.210.7 --sendCommand readCommandResponse: replyLineQP: 501 Syntax error in IP address --readCommandResponse --setupActiveDataSocket Failed to setup active data socket. Try using passive mode instead. --setupDataConnection
cool. so i don't have to write my own service to get my external ip :) Like above, there is an error in the syntax for the last PORT command. i think "PORT 80,130,210,7,196,213" would be the correct syntax. Here some log:
setupActiveDataSocket: Using ephemeral port range for Active data connection. dataPort: 50389 portIpAddress: 192.110.130.33 MyIPv4: 192,110,130,33,196,213 sendCommand: sendingCommand: PORT 192,110,130,33,196,213 --sendCommand readCommandResponse: replyLineQP: 500 I won't open a connection to 192.110.130.33 (only to 80.130.210.7) --readCommandResponse Retrying PORT command. sendCommand: sendingCommand: PORT 80.130.210.7 --sendCommand readCommandResponse: replyLineQP: 501 Syntax error in IP address --readCommandResponse --setupActiveDataSocket Failed to setup active data socket. Try using passive mode instead. --setupDataConnection
regards
Marco
I made the fix and re-uploaded to:
32-bit Download: http://www.chilkatsoft.com/download/preRelease/chilkat-9.5.0-x86-vc10.zip
64-bit Download: http://www.chilkatsoft.com/download/preRelease/chilkat-9.5.0-x86_64-vc10.zip