Strange FTP Behavior

Modem: HL7588
Modem-Firmware: RHL75xx.A.2.15.151600.201809201422.x7160_3
ATT&T in the States if that matters.

I have been having trouble exiting DATA mode after uploading a file with +KFTPSND.
The connection is established fine (I get CONNECT) but once I finish sending data I could not exit DATA mode.
I tried –EOF–Pattern– and +++ , neither worked.

Now the strange part, if before I establish the FTP connection I run AT+KSRAT=2 then I can send the file and exit data mode with no problem using the –EOF–Pattern– .

So for now I switch to UMTS, upload the file, and then switch back to LTE (7).

Has anyone else seen this behavior?

Also, I have no problem downloading with FTP while on LTE.

Break down pseudo code:
AT+KFTPCFG=1 , “” , " User" , “password” ,21,0,1
OK (get session ID here)
---------SEND DATA HERE------
(pause one second)

Hi @sguerreri,
I am not sure the exact scenario which is getting strange FTP behavior. Please share more detail to understand your problem.

Which KSRAT mode is using in this step? (2,5,6 or 7?)

If you set KSRAT=2 (UMTS only) then establishing the FTP connection, the module exited data mode successfully??

So the problem you is getting is the module is not able to exit Data mode when it is LTE or UMTS? Please confirm
I tried to send data to FTP server as below with KSRAT=7, it works fine
+KFTP_IND: 2,1


+KFTP_IND: 2,2,143

+KFTP_IND: 2,2,143

Thanks for the reply, I’ll try to answer all your questions.

Which KSRAT mode is using in this step? (2,5,6 or 7?)

If KSRAT is set to ‘7’, I can do all the FTP steps except ‘–EOF–Pattern–’.
So I am stuck in DATA mode. I send it but the module never exits DATA mode (i receive no ‘OK’ or ‘+KFTP_IND:…’ response) .

If you set KSRAT=2 (UMTS only) then establishing the FTP connection, the module exited data mode successfully??

Yes. If KSRAT is set to ‘2’, everything works fine. I can send files and exit DATA mode with ‘–EOF–Pattern–’ without a problem.

So the problem is getting the module to exit DATA mode when using FTP while KSRAT=7.

Sorry for not being clear before, I will run more tests on my end and try to post the module’s responces.


Hi @sguerreri,
Thanks for your information. In KSRAT= 7, the module will search 4G first, if it is not available the module will use 3G. Do you know if the module is using 4G or 3G in this mode (ksrat=7)? Have you tried to use ksrat=5 (4G only). Do you know if there is any limitation in 4G from your operator?

Do you know if the module is using 4G or 3G in this mode (ksrat=7)?

I am connected to 4G when KSRAT=7. In fact I have forced 4G with ksrat=5.

I don’t think there are any limitations because if i manually send the AT commands (using busybox microcom) it works BUT only when I send smaller amounts of data (<1000 bytes).

Could this be a timing issue? Are there any timing considerations I need to keep in mind when sending >500Kb of data 5Kb at a time? Or when I send the EOF Pattern? Let me explain with sudo code:

//open the session and get the ID
session_id = AT+KFTPCFG=1 , “” , "User" , “pw” ,21,0,1

//start sending this file over FTP

//setup to read in the file we want to send
FileInputStream fin = new FileInputStream(f2);
byte array b = new byte[5000];

//loop until we reach the end of the file
while ((bytesRead = != -1) {
          mFileOutputStream.write(b, 0, bytesRead);
          up_count += bytesRead;
//send the EOF pattern

This fails every time I run it connected to LTE, but it works fine when my module is connected to 3G.

I have tried playing with the size of the buffer (from 1Kb to 16Kb), how long I sleep before sending another buffer (anywhere from 0 to 2 seconds), and how long I sleep before sending the EOF Pattern after the file is sent.

Could you please try to send much larger amounts of data? Maybe put 4 or 5Kb of data in your clipboard and CTRL+V it 10 times once you have a connection open, then try to send the EOF Pattern.

I also tried to keep the data transfer small and use the append option if +KFTPSND but I could not get this to work because the file would get over-written each time. It is like the ‘append’ option is being ignored.

I am about to give up on FTP as a method of uploading large amounts of data and move on to HTTP Post.

Thanks for your help!

Hi @sguerreri,
Sorry for the late reply. I tried running the script with the big data (5MB) it works fine on HL7588 ver 2.15. The data is sent and verified correctly. From your script, it looks like the module doesn’t have enough time out to send a large date. You can extend the time out then try again. I used

Also tested “append” option, it works as expected. The file already exists then the data is appended at the end of the file
Please share any concerns you have

1 Like