This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9160 issues with Pure-FTPd? AT#XFTP serial_lte_modem and how to force use of TLS for FTP?

When I try to connect to my Pure-FTPd server I always get an error when trying to login, but If I use a public server like... https://dlptest.com/ftp-test/ it's fine. This might have something to do with TLS being enabled on most of the servers I need to connect to. But I could be wrong?

220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 00:25. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
504 Unknown command

ERROR

All my connect code is pretty much just as the documentation says... 

sprintf(buf, "AT#XFTP=\"open\",\"%s\",\"%s\",\"%s\"", username, pass, hostname);

I am at a loss, and just another thing to note, the normal documentation here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/FTP_AT_commands.html

really should be updated with the much more detailed information here: https://github.com/nrfconnect/sdk-nrf/blob/a0fc38d842f4772c04f957b2d473644b567a1950/applications/serial_lte_modem/doc/slm_testing.rst#ftp-at-commands

Thanks,

Kyle

  • Hello Markus,

    I have still not been able to get either working, FTP is far preferred over the HTTP stuff. But i have got the HTTP to connect but wont properly send data packets in a POST request for some reason.

    Thanks,

    Kyle

  • Just more info, after comparing FTP logs from the modem vs FileZilla with UTF* forced on, it appears the FW sees the 504 error and assumes the server is going to give them the boot. But oddly enough FileZilla just continues on and the server accepts them. I am trying to make these changes to the modem FW now.

    21:16:46	Status:	Resolving address of  ********************
    21:16:46	Status:	Connecting to  ********************:21...
    21:16:46	Status:	Connection established, waiting for welcome message...
    21:16:46	Trace:	CFtpControlSocket::OnReceive()
    21:16:46	Response:	220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
    21:16:46	Response:	220-You are user number 1 of 50 allowed.
    21:16:46	Response:	220-Local time is now 21:16. Server port: 21.
    21:16:46	Response:	220-This is a private system - No anonymous login
    21:16:46	Response:	220-IPv6 connections are also welcome on this server.
    21:16:46	Response:	220 You will be disconnected after 15 minutes of inactivity.
    21:16:46	Trace:	CFtpLogonOpData::ParseResponse() in state 1
    21:16:46	Trace:	CControlSocket::SendNextCommand()
    21:16:46	Trace:	CFtpLogonOpData::Send() in state 5
    21:16:46	Status:	Plain FTP is insecure. Please switch to FTP over TLS.
    21:16:46	Trace:	CFtpControlSocket::SetAsyncRequestReply
    21:16:46	Trace:	CControlSocket::SendNextCommand()
    21:16:46	Trace:	CFtpLogonOpData::Send() in state 6
    21:16:46	Command:	USER   ********************
    21:16:46	Trace:	CFtpControlSocket::OnReceive()
    21:16:46	Response:	331 User ******************** OK. Password required
    21:16:46	Trace:	CFtpLogonOpData::ParseResponse() in state 6
    21:16:46	Trace:	CControlSocket::SendNextCommand()
    21:16:46	Trace:	CFtpLogonOpData::Send() in state 6
    21:16:46	Command:	PASS ********************
    21:16:46	Trace:	CFtpControlSocket::OnReceive()
    21:16:46	Response:	230 OK. Current restricted directory is /
    21:16:46	Trace:	CFtpLogonOpData::ParseResponse() in state 6
    21:16:46	Trace:	CControlSocket::SendNextCommand()
    21:16:46	Trace:	CFtpLogonOpData::Send() in state 10
    21:16:46	Command:	OPTS UTF8 ON
    21:16:46	Trace:	CFtpControlSocket::OnReceive()
    21:16:46	Response:	504 Unknown command
    21:16:46	Trace:	CFtpLogonOpData::ParseResponse() in state 10
    21:16:46	Status:	Logged in
    21:16:46	Trace:	Measured latency of 71 ms
    21:16:46	Trace:	CFtpControlSocket::ResetOperation(0)
    21:16:46	Trace:	CControlSocket::ResetOperation(0)
    21:16:46	Trace:	CFtpLogonOpData::Reset(0) in state 15
    21:16:46	Trace:	CFileZillaEnginePrivate::ResetOperation(0)
    21:16:46	Status:	Retrieving directory listing...
    21:16:46	Trace:	CControlSocket::SendNextCommand()
    21:16:46	Trace:	CFtpListOpData::Send() in state 0
    21:16:46	Trace:	CFtpChangeDirOpData::Send() in state 0
    21:16:46	Trace:	CFtpChangeDirOpData::Send() in state 1
    21:16:46	Command:	PWD
    21:16:46	Trace:	CFtpControlSocket::OnReceive()
    21:16:46	Response:	257 "/" is your current location
    21:16:46	Trace:	CFtpChangeDirOpData::ParseResponse() in state 1
    21:16:46	Trace:	CFtpControlSocket::ResetOperation(0)
    21:16:46	Trace:	CControlSocket::ResetOperation(0)
    21:16:46	Trace:	CFtpChangeDirOpData::Reset(0) in state 1
    21:16:46	Trace:	CFtpListOpData::SubcommandResult(0) in state 1
    21:16:46	Trace:	CControlSocket::SendNextCommand()
    21:16:46	Trace:	CFtpListOpData::Send() in state 2
    21:16:46	Trace:	CFtpControlSocket::ResetOperation(0)
    21:16:46	Trace:	CControlSocket::ResetOperation(0)
    21:16:46	Trace:	CFtpListOpData::Reset(0) in state 2
    21:16:46	Status:	Directory listing of "/" successful
    21:16:46	Trace:	CFileZillaEnginePrivate::ResetOperation(0)
    21:31:46	Trace:	CFtpControlSocket::OnReceive()
    21:31:46	Response:	421 Timeout - try typing a little faster next time
    21:31:46	Trace:	Unexpected reply, no reply was pending.
    21:31:46	Trace:	CFtpControlSocket::OnReceive()
    21:31:46	Status:	Connection closed by server
    21:31:46	Trace:	CRealControlSocket::DoClose(66)
    21:31:46	Trace:	CControlSocket::DoClose(66)
    21:31:46	Trace:	CFtpControlSocket::ResetOperation(66)
    21:31:46	Trace:	CControlSocket::ResetOperation(66)
    21:31:46	Trace:	CFileZillaEnginePrivate::ResetOperation(66)

    I mean this is the proper behavior, from a strictly documentation point of view. But clearly clients ignore it.

    edit: here is a video kind of showing my thought process and what is going wrong. Kind of lost my composure a little half way through so just ignore that please. its been a LONGGG few days: https://www.youtube.com/watch?v=SfcV6IB79wQ I pretty much have not slept since Monday morning other then a 3 hour nap earlier today.

  • OK!!! I FIXED IT

    I changed the UTF8 section of the  ftp_open function FW to the following...

    	/* Send UTF8 option */
    	sprintf(ctrl_buf, CMD_OPTS, "UTF8 ON");
    	ret = do_ftp_send_ctrl(ctrl_buf, strlen(ctrl_buf));
    	if (ret) {
    		close(client.sock);
    		return ret;
    	}
    	ret = do_ftp_recv_ctrl(true, FTP_CODE_200);
    	if (ret != FTP_CODE_200) {
              if (ret != FTP_CODE_500){ //
                    close(client.sock);
                    return ret;
              } else {
                ret = FTP_CODE_200;
              }
    	}

    And now everything functions! upload, download, ls ect!!!

    EDIT: AND ALL THIS WAS FIXED IN SDK 1.6.0 that was like... just released omg

  • Thanks a lot for the feedback, Kyle! I’m glad to hear that you could resolve the issue and posted your solution. This is really appreciated!

    Cheers,

    Markus

Related