Callback issue in the FTP get function of 9160

How to determine if the download is complete when downloading files from the FTP server using the ftp_get function?

Although Ctrl_cb will return code, in my actual testing, when downloading a large file, the download was not completed yet, and Ctrl_cb already returned 226 code indicating that the transfer was completed. However, there was no callback message when the download was actually completed.

I haven't tested the ftp put function yet, may there be similar issues as well?

  • Hi,

    Documentation for SLM sample specifies that client behavior may vary depending on the server that is used for testing. Which FTP server did you use?

    You could try to test FTP connection using FTP AT commands.

    llly said:
    when I downloaded about one-third of the time, it gave me a notification that the download was completed

    Where is this shown in the log?

    Best regards,
    Dejan

  • Hi dejans

    I am using our own FTP server.

    The current log does not display 226, only a -116 connection timeout code. When downloading a relatively small file, the 226 code can be returned normally when the download is completed, but when downloading a large file, I think it should be because the download time exceeded the timeout time, so he thought the command timed out, which ultimately led to a return of -116?

    In other words, when downloading a large file, after a period of time (about one or two minutes?), if the download is not completed yet, ftp_get will return a -116 timeout code. How can we make it return 226 only when the download is completed, instead of -116?

  • Hi,

    In the FTP client library, there is CONFIG_FTP_CLIENT_KEEPALIVE_TIME option which is by default set to 60 seconds. You could try either to increase this value or turn the KEEPALIVE option off by changing its value to 0.

    Best regards,
    Dejan

  • Hi dejans

    I tested CONFIG_FTP_CLIENT_KEEPALIVE_TIME, but it didn't work. Instead, I modified FTP_DATA_TIMEOUT_SEC in ftp_client. c to solve this problem. It may not be the best solution, but currently it's not a big problem. Simply put, the time for ftp_get cannot exceed FTP_DATA_TIMEOUT_SEC, otherwise it will return -116, with a default of 60 seconds. Therefore, I will change this value to a few minutes. Perhaps you can improve this place a bit? But for me, this problem has been solved.

    Anyway, thank you for your help.

  • Perhaps I should have been more detailed.

    The specific issue is that after calling ftp_get, the device should have created an FTP thread to download files. However, if the download time exceeds FTP_DATA_TIMEOUT_SEC, ftp_get returns a timeout code and exits. At this time, the FTP thread is not closed, but continues to run, so the callback function passed in ftp_init is still called.

Related