login about faq

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

asked Apr 14 at 05:17

schraube's gravatar image

schraube
1


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..

link

answered Apr 14 at 08:08

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

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:

  1. By default, Chilkat will NOT try to bind to the IP address specified by the ForceIpAddress property.
  2. You may use a special "bind-" prefix in the ForceIpAddress property to cause the data socket to be bound to the ForceIpAddress property. For example, put_ForceIpAddress("bind-80.130.210.228")
  3. There was an undocumented feature (which will become documented) where you can set the ForceIpAddress property equal to the keyword "control". In this case, the IP address of the control connection is used.
  4. Chilkat will now recognize the error message "I won't open a connection to...", parses it, and will automatically retry using the IP address from the message.
link

answered Apr 14 at 10:22

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Thanks for your reply, chilkat!

  1. 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.

  2. nice feature, i can't test it :)

  3. 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

  4. 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

link

answered Apr 15 at 03:07

schraube's gravatar image

schraube
1

Thanks! I goofed and wasn't thinking clearly when implementing the auto-retry. I'll make the fix...

(Apr 15 at 11:08) chilkat ♦♦
link

answered Apr 15 at 13:39

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

it works now. thanks!

(Apr 18 at 09:16) schraube
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×90

Asked: Apr 14 at 05:17

Seen: 564 times

Last updated: Apr 18 at 09:16

powered by OSQA