none
Issues in FTP connection. RRS feed

  • Question

  • Hi All,

    I am trying to connect FTP in command prompt but after few seconds data connection is getting closed, and I'm not at all able to connect through browser. I  have enabled SYSGEN_FTP catalog item in the OS design.

    In the command prompt I'm giving the commands in the following order

                                               >ftp (ip address)

    User<(ip address):<none>>:anonymous

            Password:(entering password)

            ftp>dir

    And Can you please tell how to connect to the browser ?

    Thanks & Regards

    Neha

    Tuesday, August 18, 2015 1:56 PM

All replies

  • For the networking issue, I think you'll have to capture packets and see who is breaking the connection and (hopefully) why. Look for who set the RST bit in a TCP packet first, and error codes in preceding packets, etc.

    So if you enter a URL starting with FTP: in the browser, it doesn't work? Something like FTP://192.168.101.45?

    Paul T.

    Tuesday, August 18, 2015 7:32 PM
  • Hi Paul,

    Thanks for the reply, I have tried connecting FTP with the browser the way you told like ftp://192.168.1.51 but it's not working.

    And the registry settings are like this

    ;enable telnet server

    [HKEY_LOCAL_MACHINE\COMM\TELNETD]

    "UseAuthentication"=dword:0 ;Authentication is not required
    "IsEnabled"=dword:1 ;Set to 1 to enable Telnet Server and to 0 to disable.

    ;enable ftp server

    [HKEY_LOCAL_MACHINE\COMM\FTPD]
    "IsEnabled"=dword:1
    "UseAuthentication"=dword:0
    "AllowAnonymous"=dword:1
    "AllowAnonymousUpload"=dword:1
    "AllowAnonymousVroots"=dword:1
    "DefaultDir"="\\"

    and modified Idle Timeout from 0x0000012c to 0xEFFFFFFF but still it is not getting connected.

    Regards

    Neha


    • Edited by chauhanneha Wednesday, August 19, 2015 2:22 PM
    Wednesday, August 19, 2015 10:09 AM
  • Hi Neha,

    I had a similar issue. I resolved it by allowing the accept call within the CFtp::Run method to retry. So, instead of having the function return, I simply called continue within the loop. See below:

    for (;;)
    {
    int iSockets;
    LONG j;

    memcpy(&sockSet, &sockSetOrig, sizeof(FD_SET));

    IFDBG(svslog_DebugOut(LOG_VERBOSE, L"FTPD: Calling select()....\r\n"));
    iSockets = select(0,&sockSet,NULL,NULL,NULL);

    if (iSockets == 0 || iSockets == SOCKET_ERROR) 
    {
    IFDBG(svslog_DebugOut(LOG_ERRORS, L"select() returned %d\r\n", iSockets));
    break;
    }

    IFDBG(svslog_DebugOut(LOG_VERBOSE, L"FTPD: Received %d incoming connections!!\r\n", iSockets));

    for (j = 0; j < iSockets; j++) 
    {
    if (INVALID_SOCKET == (sockClient = accept(sockSet.fd_array[j], NULL, NULL)))
    {
    IFDBG(svslog_DebugOut(LOG_ERRORS, L"accept() failed\r\n"));
    continue; // Was a call to return TRUE;
    }

    I also changed CloseListenSockets:

    VOID CloseListenSockets(SOCKET *aSocks, DWORD dwNumSocks)
    {
    //close server thread and socket
    //LINGER li;
    //li.l_onoff = 1;
    //li.l_linger = 0;
        RETAILMSG( 1, (_T("<FTP> CloseListenSockets: NumSocks %d\r\n"), dwNumSocks));
    for (DWORD i=0; i<dwNumSocks; i++)
    {
            RETAILMSG( 1, (_T("<FTP> CloseListenSockets: Closing %d\r\n"), aSocks[i]));
    if (aSocks[i] != INVALID_SOCKET)
    {
                static char recvBuf[1024];  // buffer shared by all socket closers

                // We are done sending
                shutdown(aSocks[i], SD_SEND);

                // We are waiting for data to be delivered from the peer.tcp to the peer.app.
                // We can only know that this has happened when the peer.app does a shutdown and peer.tcp sends FIN.
                // Unfortunately, we cannot afford to tie up this thread for minutes on end.
                // So we will give the peer a short time to read the data and then close the socket.
                // Notifies are at least 200ms apart. We want this thread freed before then.   Thus 180ms.
                int rcvto = 180;    // 180ms
                setsockopt(aSocks[i], SOL_SOCKET, SO_RCVTIMEO, (char*)&rcvto, sizeof(rcvto));
                while (recv(aSocks[i], recvBuf, sizeof(recvBuf), 0) > 0)
                {
                    ;
                }

                // Now kill the socket
    //setsockopt(aSocks[i], SOL_SOCKET, SO_LINGER, (const char *)&li, sizeof(li));
    closesocket(aSocks[i]);
    aSocks[i] = INVALID_SOCKET;
    }
    }
    }

    Regards,

    Jim

    Thursday, August 20, 2015 3:27 AM
  • Hi,

    The final registry entries in the NK.bin are seen as below


    [HKEY_LOCAL_MACHINE\Comm\FTPD]
        "AllowAnonymous"=dword:1
        "AllowAnonymousUpload"=dword:1
        "AllowAnonymousVroots"=dword:0
        "BaseDir"="\\Windows"
        "DebugOutputChannels"=dword:2
        "DebugOutputMask"=dword:17
        "DefaultDir"="\\"
        "IdleTimeout"=dword:EFFFFFFF
        "IsEnabled"=dword:1
        "LogSize"=dword:1000
        "UseAuthentication"=dword:0

    We have cloned the FTPD from _WINCEROOT\PUBLIC\Servers\SDK\Samples\FTPD

    Compiled as a subproject and modified the source as given by Jim.

    But, we still see the same issue. 

    Below is the FTP log from the Windows Command prompt.

    C:\Users\ftp 192.168.13.77
    Connected to 192.168.13.77.
    220 Service ready for new user.
    User (192.168.13.77:(none)): anonymous
    331 Anonymous access allowed, send identity (e-mail name) as password.
    Password:
    230 User logged in, proceed.
    ftp> dir
    200 Command okay.
    150 File status okay; about to open data connection.
    01-01-98  04:00       <DIR>          Network
    01-01-98  04:00       <DIR>          Mounted_Volume
    226 Closing data connection.
    ftp: 99 bytes received in 0.01Seconds 9.90Kbytes/sec.
    ftp> dir
    200 Command okay.
    150 File status okay; about to open data connection.
    01-01-98  04:00       <DIR>          Network
    01-01-98  04:00       <DIR>          Mounted_Volume
    01-01-98  04:00       <DIR>          Storage_Card
    226 Closing data connection.
    ftp: 150 bytes received in 0.00Seconds 150000.00Kbytes/sec.
    ftp> dir
    200 Command okay.
    150 File status okay; about to open data connection.
    226 Closing data connection.
    ftp>

    We see two problems
    FTPD is not consistent and the connection closes. We are in the process of sniffing the packets with wireshark, once the data is available it will be posted heres
    Other problem is we never able to connect to ftp from the EXPLORER.

    From the Wireshark we see the below packets



    730 93.149863000 192.168.13.77 192.168.13.99 TCP 60 20→56313 [RST, ACK] Seq=151 Ack=1 Win=0 Len=0


    The compact 7 device iP Address is 77 and Host PC IP Address is 99. So, it looks the device sets RST.

    Is this understanding correct. If so how to fix this issues.

    Regards

    Neha

    Thursday, August 20, 2015 1:52 PM
  • Hi Neha,

    Are you seeing this on upload or download? I've see this when getting, but putting seems to be fine.

    Jim

    Friday, August 21, 2015 1:41 PM
  • Hi Jim,

    Putting and getting are working fine. Did you face any problem while connecting ftp sever with  browser ??

    We are not able to connect it.

    Regards

    Neha

    Tuesday, August 25, 2015 5:40 AM
  • Hi,

    Can anyone tell how to establish ftp connection in winCE 7.0 through browser ??

    when I'm trying to establish ftp connection through browser I'm getting these packets( from wireshark)

    12 13.663999000 192.168.15.5 192.168.15.6 TCP 66 52483→21 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=4 SACK_PERM=1
    15 13.664718000 192.168.15.6 192.168.15.5 TCP 66 21→52483 [SYN, ACK] Seq=0 Ack=1 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1
    16 13.665297000 192.168.15.5 192.168.15.6 TCP 54 52483→21 [ACK] Seq=1 Ack=1 Win=65700 Len=0
    17 13.671393000 192.168.15.6 192.168.15.5 FTP 87 Response: 220 Service ready for new user.
    18 13.671713000 192.168.15.5 192.168.15.6 FTP 70 Request: USER anonymous
    19 13.675404000 192.168.15.6 192.168.15.5 FTP 126 Response: 331 Anonymous access allowed, send identity (e-mail name) as password.
    20 13.675619000 192.168.15.5 192.168.15.6 FTP 68 Request: PASS IEUser@
    21 13.690431000 192.168.15.6 192.168.15.5 FTP 84 Response: 230 User logged in, proceed.
    22 13.690735000 192.168.15.5 192.168.15.6 FTP 61 Request: CWD /
    23 13.695346000 192.168.15.6 192.168.15.5 FTP 98 Response: 250 Requested file action okay, completed.
    24 13.695700000 192.168.15.5 192.168.15.6 FTP 62 Request: TYPE A
    25 13.696360000 192.168.15.6 192.168.15.5 FTP 73 Response: 200 Command okay.
    26 13.696923000 192.168.15.5 192.168.15.6 FTP 60 Request: PASV
    27 13.700366000 192.168.15.6 192.168.15.5 FTP 103 Response: 227 Entering Passive Mode (192,168,15,6,192,0).
    31 13.701432000 192.168.15.5 192.168.15.6 FTP 60 Request: LIST
    32 13.908441000 192.168.15.6 192.168.15.5 TCP 60 21→52483 [ACK] Seq=248 Ack=58 Win=17408 Len=0
    34 61.628271000 192.168.15.5 192.168.15.6 TCP 54 52483→21 [RST, ACK] Seq=58 Ack=248 Win=0 Len=0

    Regards,

    Neha

    Thursday, September 3, 2015 2:36 PM