FTP server on esp8266 and esp32
When I develop a new solution, I’d like to divide the application into layers, and so I’d like to focus my attention on only one aspect at a time.
In detail, I separate the REST layer (written inside the microcontroller) and the Front-End (composed in Angular, React/Redux, or vanilla JS), so I’d like to upload a new web interface directly to the microcontroller via FTP.
For static information (Web pages, for example) that do not change frequently, esp8266 or esp32 have internal SPIFFS (SPI Flash File System). You can upload data via Arduino IDE as explained in the article “WeMos D1 mini (esp8266), integrated SPIFFS Filesystem” for esp8266 or “ESP32: integrated SPIFFS FileSystem” for esp32 or with LittleFS “WeMos D1 mini (esp8266), integrated LittleFS Filesystem” for esp8266 or “ESP32: integrated LittleFS FileSystem” for esp32 or “ESP32: integrated FFat (FAT/exFAT) FileSystem” but for fast operation and future support It usefully uses FTP.
I find a simple library that works quite well, and It’s not hungry for resources; you can find It here.
In time, this library becomes buggy and had deficient support, so I fix It, and now you can retrieve the library from here.
Library
The library is available directly from the Library Manager of Arduino IDE.
Or the source code from GitHub.
You can find my library here.
To download.
Click the DOWNLOADS button in the top right corner, and rename the uncompressed folder SimpleFTPServer.
Check that the SimpleFTPServer contains FtpServer.cpp, FtpServer.h, FtpServerKey.h e SimpleFTPServer.h .
Place the SimpleFTPServer library folder in your /libraries/ folder.
You may need to create the libraries subfolder if it’s your first library.
Restart the IDE.
Select FS on esp8266
You can also enable LittleFS for esp8266 by editing the line in the FtpServerKey.h file
#define DEFAULT_STORAGE_TYPE_ESP8266 STORAGE_SPIFFS
in
#define DEFAULT_STORAGE_TYPE_ESP8266 STORAGE_LITTLEFS
Usage
Here is an example for esp8266
/*
* WeMos D1 mini (esp8266)
* Start FTP server to upload data on SPIFFS
* by Mischianti Renzo <https://mischianti.org>
*
* https://mischianti.org/wemos-d1-mini-esp8266-integrated-spiffs-filesistem-part-2/
*
*/
#include "Arduino.h"
#include <ESP8266WiFi.h>
#include <SimpleFtpServer.h>
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASS";
FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
void setup(void){
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
/////FTP Setup, ensure SPIFFS is started before ftp; /////////
if (SPIFFS.begin()) {
// SPIFFS.format();
Serial.println("SPIFFS opened!");
ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. set ports in ESP8266FtpServer.h (default 21, 50009 for PASV)
}
}
void loop(void){
ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
}
Select FS on esp32
You can also enable LittleFS for esp32 by editing the line in the FtpServerKey.h file
#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SPIFFS
in
#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_LITTLEFS
or this for FFAT
#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_FFAT
Here the complete list of options.
#define STORAGE_SDFAT1 1 // Library SdFat version 1.4.x
#define STORAGE_SDFAT2 2 // Library SdFat version >= 2.0.2
#define STORAGE_SPIFM 3 // Libraries Adafruit_SPIFlash and SdFat-Adafruit-Fork
#define STORAGE_FATFS 4 // Library FatFs
#define STORAGE_SD 5 // Standard SD library (suitable for Arduino esp8266 and esp32
#define STORAGE_SPIFFS 6 // SPIFFS
#define STORAGE_LITTLEFS 7 // LITTLEFS
#define STORAGE_SEEED_SD 8 // Seeed_SD library
#define STORAGE_FFAT 9 // ESP32 FFAT
#define STORAGE_SD_MMC 10 // SD_MMC library
Not all are compatible with our device.
Usage
Here for esp32
/*
* ESP32 Dev Kit (esp32)
* Start FTP server to upload data on SPIFFS
* by Mischianti Renzo <https://mischianti.org>
*
* https://mischianti.org/wemos-d1-mini-esp8266-integrated-spiffs-filesistem-part-2/
*
*/
#include <WiFi.h>
#include "SPIFFS.h"
#include <SimpleFtpServer.h>
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASS";
FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
void setup(void){
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
/////FTP Setup, ensure SPIFFS is started before ftp; /////////
if (SPIFFS.begin(true)) {
Serial.println("SPIFFS opened!");
ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. set ports in ESP8266FtpServer.h (default 21, 50009 for PASV)
}
}
void loop(void){
ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
}
This library support only passive mode and you must force only one connection at time.
I use FileZilla as a client, and you can download It here; It is pretty simple to use and configure.
First, you must go on Manage site --> New site
and now set this parameter:
- Select
FTP
as protocol; - Select
Use plain FTP (insecure)
; - Set your login and password (you choose that in the sketch);
- Than on
Trasfer settings
selectMaximun number of connection
equal 1; - Now connect to your device.
Now, you can manage your SPIFFS with drag and drop.
Remember that SPIFFS does not manage folders, so all files must be flat.
Test
To check the upload, you can use the simple sketch used in the SPIFFS article linked up:
/*
* WeMos D1 mini (esp8266)
* SPIFFS get info, read dir and show all file uploaded
* add a data folder to use with esp8266 data uploader
* by Mischianti Renzo <https://mischianti.org>
*
* https://mischianti.org/wemos-d1-mini-esp8266-integrated-spiffs-filesistem-part-2/
*
*/
#include "Arduino.h"
#include "FS.h"
void setup()
{
Serial.begin(112500);
delay(500);
Serial.println(F("Inizializing FS..."));
if (SPIFFS.begin()){
Serial.println(F("done."));
}else{
Serial.println(F("fail."));
}
// To format all space in SPIFFS
// SPIFFS.format()
// Get all information of your SPIFFS
FSInfo fs_info;
SPIFFS.info(fs_info);
Serial.println("File sistem info.");
Serial.print("Total space: ");
Serial.print(fs_info.totalBytes);
Serial.println("byte");
Serial.print("Total space used: ");
Serial.print(fs_info.usedBytes);
Serial.println("byte");
Serial.print("Block size: ");
Serial.print(fs_info.blockSize);
Serial.println("byte");
Serial.print("Page size: ");
Serial.print(fs_info.totalBytes);
Serial.println("byte");
Serial.print("Max open files: ");
Serial.println(fs_info.maxOpenFiles);
Serial.print("Max path length: ");
Serial.println(fs_info.maxPathLength);
Serial.println();
// Open dir folder
Dir dir = SPIFFS.openDir("/");
// Cycle all the content
while (dir.next()) {
// get filename
Serial.print(dir.fileName());
Serial.print(" - ");
// If element have a size display It else write 0
if(dir.fileSize()) {
File f = dir.openFile("r");
Serial.println(f.size());
f.close();
}else{
Serial.println("0");
}
}
}
void loop()
{
}
Test with callback
An interesting feature I added recently was the callback on some action
/*
* FtpServer esp8266 and esp32 with SPIFFS
*
* AUTHOR: Renzo Mischianti
*
* https://mischianti.org/ftp-server-on-esp8266-and-esp32
*
*/
#ifdef ESP8266
#include <ESP8266WiFi.h>
#elif defined ESP32
#include <WiFi.h>
#include "SPIFFS.h"
#endif
#include <SimpleFTPServer.h>
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASS";
FtpServer ftpSrv; //set #define FTP_DEBUG in ESP8266FtpServer.h to see ftp verbose on serial
void _callback(FtpOperation ftpOperation, unsigned int freeSpace, unsigned int totalSpace){
switch (ftpOperation) {
case FTP_CONNECT:
Serial.println(F("FTP: Connected!"));
break;
case FTP_DISCONNECT:
Serial.println(F("FTP: Disconnected!"));
break;
case FTP_FREE_SPACE_CHANGE:
Serial.printf("FTP: Free space change, free %u of %u!\n", freeSpace, totalSpace);
break;
default:
break;
}
};
void _transferCallback(FtpTransferOperation ftpOperation, const char* name, unsigned int transferredSize){
switch (ftpOperation) {
case FTP_UPLOAD_START:
Serial.println(F("FTP: Upload start!"));
break;
case FTP_UPLOAD:
Serial.printf("FTP: Upload of file %s byte %u\n", name, transferredSize);
break;
case FTP_TRANSFER_STOP:
Serial.println(F("FTP: Finish transfer!"));
break;
case FTP_TRANSFER_ERROR:
Serial.println(F("FTP: Transfer error!"));
break;
default:
break;
}
/* FTP_UPLOAD_START = 0,
* FTP_UPLOAD = 1,
*
* FTP_DOWNLOAD_START = 2,
* FTP_DOWNLOAD = 3,
*
* FTP_TRANSFER_STOP = 4,
* FTP_DOWNLOAD_STOP = 4,
* FTP_UPLOAD_STOP = 4,
*
* FTP_TRANSFER_ERROR = 5,
* FTP_DOWNLOAD_ERROR = 5,
* FTP_UPLOAD_ERROR = 5
*/
};
void setup(void){
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
/////FTP Setup, ensure SPIFFS is started before ftp; /////////
/////FTP Setup, ensure SPIFFS is started before ftp; /////////
#ifdef ESP32 //esp32 we send true to format spiffs if cannot mount
if (SPIFFS.begin(true)) {
#elif defined ESP8266
if (SPIFFS.begin()) {
#endif
ftpSrv.setCallback(_callback);
ftpSrv.setTransferCallback(_transferCallback);
Serial.println("SPIFFS opened!");
ftpSrv.begin("esp8266","esp8266"); //username, password for ftp. (default 21, 50009 for PASV)
}
}
void loop(void){
ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
// server.handleClient(); //example if running a webserver you still need to call .handleClient();
}
Here is a simple upload of a README.md file.
.......
Connected to reef-casa-sopra
IP address: 192.168.1.127
LittleFS opened!
FTP: Connected!
FTP: Upload start!
FTP: Upload of file README.md byte 1072
FTP: Upload of file README.md byte 3120
FTP: Upload of file README.md byte 3559
FTP: Finish transfer!
FTP: Free space change, free 1019904 of 1036288!
Thanks.
- SimpleFTPServer library: esp32 and esp8266 how to
- SimpleFTPServer library: WioTerminal how to
- FTP server on STM32 with w5500, enc28j60, SD Card, and SPI Flash
Good afternoon
I’ve been looking for and testing some examples of FTPServer with esp32 and I found yours (great by the way) works perfectly as WIFIClient …
Would it be possible to use WIFI as WIFI_AP?
Hi Rodrigo,
I haven’t tried it, but I don’t think there are any contraindications, FTP server is independent from WIFI configuration.
Bye Renzo
Hi, how can i turn wifi station mode to the wifi acces point mode? İ want to connect to the esp8266 and then upload file.
Hi Kemran,
Yes I already tested It, please open a Forum topic in this section, so I can attach file with the code.
Bye Renzo
Thank you so much for your reply. I opened topic.
Hello, thanks for this library. I am using a Sparkfun ESP32 Thing microprocessor with an SD card attached for data logging purposes and connected to a WiFi network. I am aiming to be able to download files from the SD card via ftp (I am using Filezilla). The example script SimpleFTPserver works and I can successfully download the documents stored in SPIFFS via Filezilla.
Based on the commentary in the article I thought that I might be able to modify FtpServerKey.h as detailed below such that I can access/point the ftp server to the SD card rather than SPIFFS:
Replace:
#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SPIFFS
with#define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SD
.However I get a series of compilation errors when I attempt this. Examples are:
I am new to this and quickly getting out of my depth.
I was wondering whether there is a simple fix to allow the ftp server to point to the SD card rather than SPIFFS?
Many thanks
Hi Cameron,
sorry, i forgot to push some files. I’m going to do that at lunch.
You must change these lines in
FtpServerKey.h
in
Bye Renzo
I push the change.
Sorry again Bye Renzo
I tried to run on ESP32, but filezilla could not coneect to the board. It kept trying to connect and timed out.
Hi Jun,
I try It now and work correctly, I think It’s better if you open a topic in the relative forum section and explain all the step and IDE configuration.
I wait your news.
Bye Renzo
hello, very well your article it allowed me to advance on my project.
I have a problem with AndFTP, (android) it does not manage to display the list of files (on filezilla win10 no problem)
can you help me ? thank you
Hi Moniteur,
I don’t remember well but I think AndFTP not support plain ftp and can’t work.
Bye Renzo
thank you for your answer, however in the FTp Server.h file you put that it is compatible: ”
* under Android:
* AndFTP
* FTP Express
* Firefox
* with a second Arduino and sketch of SurferTim at
* http://playground.arduino.cc/Code/FTP
“how else to do.
Hi Moniteur,
you are right, there was a problem in LIST command, I push the fix and will be in the next release also in the Arduino Libraries manager.
Bye Renzo
hello, hooo great from you that will help me a lot. Thank you a lot.
I’m waiting for your feedback!
hello have you had time to make the correction? Thanks for reading. have a good day
Hi Montieur,
I already do the change, but Arduino Team must do an operation and I must wait they for the update.
Try making a reminder on the issue.
If you want bypass the Arduino Team operation you must only overwrite the file FtpServer.cpp from the version that you can find in GitHub.
Give me a feedback about the fix Renzo
hello thanks for your work, i loaded from github, i replaced the FtpServer.cpp file.
the application connects well, starts loading, then nothing, a message is displayed real time out.
on the app the information I have are: site free -211 end -PASV.
j on the console the last line is: Command is: PASV
Connection management set to passive
Listening at xxx.xxx.xxx.xxx:50009
thank you for your help
Hi Monteur,
It’s better if you open a topic in the relative forum section for a technical problem, and I need the information to reproduce the problem like microcontroller, core version, client ecc.
Bye Renzo
Hi Renzo,
thanks for this great effort! On my ESP32 I was able to reproduce your ftp-server example based on SPIFFS. For certain reasons, I need to switch to an SD card as file destination.
To ensure functionality of the SD card, I followed your instructions on How to use SD card with esp32 – SD card works perfectly. Then I followed you hint in the earlier post here and made the change in FtpServerKey.h (“STORAGE_SPIFFS” –> “STORAGE_SD”; to verify that I modified the file in the right folder I additionally changed the welcome message in FtpServer.cpp located in the same directory).
Then I took your example sketch from FTPServer_Arduino_esp32_SD and changed ssid & password to my needs. In order to get the SD card up and running with the wiring from the previous example, I exchanged the line “SPI.begin(14, 2, 15, 13); //SCK, MISO, MOSI, SS” into “SPI.begin(18, 19, 23, 5); //SCK, MISO, MOSI, SS” and line “if (SD.begin(13, SPI)) {” into “if (SD.begin(5, SPI)) {“. Sketch compiles nicely, SD card is recognized, ftp server can be reached from outside (bash command line ftp client on my Ubuntu laptop, that I used successfully before with the SPIFFS/FTP example).
But: the remote directory appears to be empty (“dir”); file upload with “put” appears to work, but the target directory stays empty. Do you have any ideas? Or could you even make the destination (SPIFFS / SD) easier configurable?
Thanks, Christian
Hi Christian,
I retry now the SD sketch with STORAGE_SD configuration and all works correctly.
Open a topic in the relative forum http://mischianti.org/forums/forum/mischiantis-libraries/simple-ftp-server/ and we are going to check better.
Bye Renzo
Hi Renzo,
thanks for your quick response.
This prompted me to try it out again with “fresh” hardware: I used a new ESP32 with a new SD shield and a new SD card and – guess what – it worked!
With some re-wiring experiments I was able to trace it down to the first ESP32 I had originally used to be the source of problem.
I can come up with 2 ideas:
a) the first ESP32 simply has a hardware problem, but I have my doubts as the rest works, it is wired with a GPS sensor (serial2) and a BME280 (I2C), both writing data to an SD card or
b) SPIFFS was initialized on the first ESP32 but not on the second
Did you ever experience problems in case you switch from an SPIFFS enabled ESP32 FTP server to and SD card based?
Anyway, thanks a lot for your great work. This and also your other projects are a source of inspiration 🙂
Cheers, Christian
Hi Christian,
I used an ESP32 to test SPIFFS and SD FTP server, and I didn’t have problems.
But after a lot of different test (and issue) sometime I resolved with true parameter on begin (format on fail):
I’m pleased if you want to share your work if you want. In case, contact me on share_your_ideas@mischianti.org.
Bye Renzo
Hi Renzo,
I’ve noticed that in Arduino, when you work with LittleFS, the library name and everything else is with “LITTLEFS” I repaced all the “LittleFS” for “LITTLEFS” and everyting works fine.
Thanks for the Tutorial!
Hi josemacc,
I never used LittleFS with Arduino, I tested It only for esp8266 and esp32.
Probably is better if I invert the if with the control of ESP framework version.
Thanks Renzo
how can i run a REST API Client alongside this
There is a tutorial about rest server.
REST server on esp8266 and esp32: introduction – Part 1
Bye Renzo
Renzo, thank You for jour job. I suggest changing one line in FtpServer.h if we want to use MMC.
[…]
#elif(STORAGE_TYPE == STORAGE_SD_MMC)
#include
#include
#define STORAGE_MANAGER SD_MMC //here was SD
[…]
Ops… thanks… I fix It.
I will release a new version soon.
Bye Renzo
Help.. i get erros, how do i use SD card with sp8266 ?
Hi Alexx,
use the last version 2.1.4.
Bye Renzo
I made these changes at FtpServer.h at line 324 and now it is working fine with SD on esp8266. so never mind my previews post. i guess?
PS. i have not idea what i did, i just mix and matched in the code, i guess maximum file length should be 255 ???? and FILENAME_LENGTH 32 stands for littleFs or something else ? anyway.. for my use case it works just fine with the changes i did, i am not going to touch it since it works now.. until the lovely developer pushes an update.
Hi Alexx,
I’m going to verify It.
thanks Renzo
oK NOW i am getting no sound when i include both ESP8266Audio library along with FTP, alone each library works fine.. dunno what could be
It’s very strange, check the memory usage.
Bye Renzo
You are right, nothing wrong with FTP. completely unrelated issue. sorry to bother!
something with memory or processor.. probably memory.. i should get ESP32 instead of 8266 i got only 40kb 🙁 anywayz Thank you
Hi, Alexx!
Sorry for disturbing.
Could you give me a complete sketch for running FTP Server on ESP8266 (NodeMCU) with SD card?
Thanks!
alexline @ inbox . ru
Hi Renzo,
thanks for this library. On an ESP8266 I was able to reproduce your ftp-server example “esp8266_esp32_LittleFS.ino” based on LITTLEFS. For my project, I have added a W5500 to the ESP8266 for Ethernet connection. So I have changed line 54 of FtpServerKey.h to “#define DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP8266 NETWORK_W5100”. But if I compile my project with this change I get the following compiler errors:
What I’m doing wrong? Thanks for your response.
Albrecht
Hi Alby,
specify also the Ethernet library.
Bye Renzo
I have already posted an answer, but now I can’t see it. Ethernet library is Ethernet.h by Paul Stoffregen Version 2.0.0.
Regards
Albrecht
Hi Albi,
you are right, I test the situation, and I find a bug, so I must release a fix.
Bye Renzo
Hi Renzo, thanks for sharing this usefull library.
I want to use it for a datalogger, storing a csv on SPIFFS in a ESP32 firebeetle (16M flash), and transfer it easily to my laptop. I manage to do it with arduino exemple WebServer, but FTP server, and the script, looks much lighter and better for my purpose.
I can run the script, connect to wifi (phone and office), open SPIFFS, connect to http://FTP... but on FileZilla I can’t see my files (I’m sure there is one, i added a few lines to create one and list the files on the terminal at the end ot stup() ).
When i try to transfer from FileZilla to ESP32 I also get an error. see below
I followed the setup for FIleZilla, tried to play with spiffs partition, googled everything i could but I’m now stuck on it since yesterday.
Do you have any clue on have to solve this ?
Thanks
Hi Soil_Maker_FR,
mmm.. I need more information, please open a topic and post your code.
Bye Renzo
Thanks for repying, i will open a topic on GitHub and report all this.
I thought the problem could come from SPIFFS because I had this error message when trying to upload :
[ 20478][E][vfs_api.cpp:24] open(): File system is not mounted
[ 20540][E][vfs_api.cpp:24] open(): File system is not mounted
[ 20540][E][vfs_api.cpp:204] mkdir(): File system is not mounted
[ 20610][E][vfs_api.cpp:24] open(): File system is not mounted
[ 20823][E][vfs_api.cpp:24] open(): File system is not mounted
So i tried with LitlleFS… but nothing changed.
I will also try with an SD card and another Firebeetle Board (unfortunatly i have not other ESP32 board …). But my project will need to use ESP32 flash memory to save data… that was one of the reason to move from ATmega and SAMD21 to ESP32. By the way, this is my first project so maybe i miss something trivial with ESP32…
Hope we can fix this ! I have multiple project in mind with ESP32 to monitor soils and ecosystems… but need a simple way to access data store in his flash memory !
Hi Renzo,
thanks for the last weeks fix. With version 2.1.6 I can compile my project and the code is running. FileZilla connects to the server but the user login fails. Here the message log from FileZilla:
14:05:23 Trace: CControlSocket::SendNextCommand()
14:05:23 Trace: CFtpLogonOpData::Send() in state 0
14:05:23 Status: Connecting to 192.168.178.70:21…
14:05:23 Status: Connection established, waiting for welcome message…
14:05:23 Trace: CFtpControlSocket::OnReceive()
14:05:23 Response: 220—Welcome to Simply FTP server —
14:05:23 Response: 220— By Renzo Mischianti —
14:05:23 Trace: CFtpControlSocket::OnReceive()
14:05:23 Response: 220 — Version 2.1.6 (2023-02-02) —
14:05:23 Trace: CFtpLogonOpData::ParseResponse() in state 1
14:05:23 Trace: CControlSocket::SendNextCommand()
14:05:23 Trace: CFtpLogonOpData::Send() in state 5
14:05:23 Status: Plain FTP is insecure. Please switch to FTP over TLS.
14:05:23 Trace: CFtpControlSocket::SetAsyncRequestReply
14:05:23 Trace: CControlSocket::SendNextCommand()
14:05:23 Trace: CFtpLogonOpData::Send() in state 6
14:05:23 Command: USER ftp
14:05:30 Trace: CFtpControlSocket::OnReceive()
14:05:30 Response: 331 Ok. Password required
14:05:30 Trace: CFtpLogonOpData::ParseResponse() in state 6
14:05:30 Trace: CControlSocket::SendNextCommand()
14:05:30 Trace: CFtpLogonOpData::Send() in state 6
14:05:30 Command: PASS ***
14:05:33 Trace: CFtpControlSocket::OnReceive()
14:05:33 Response: 530 Timeout
14:05:33 Trace: CFtpLogonOpData::ParseResponse() in state 6
14:05:33 Trace: CRealControlSocket::DoClose(1094)
14:05:33 Trace: CControlSocket::DoClose(1094)
14:05:33 Trace: CFtpControlSocket::ResetOperation(1094)
14:05:33 Trace: CControlSocket::ResetOperation(1094)
14:05:33 Trace: CFtpLogonOpData::Reset(1094) in state 6
14:05:33 Error: Critical error: Could not connect to server
14:05:33 Trace: CFileZillaEnginePrivate::ResetOperation(1094)
The USER and PASS command do last very long and PASS command ends with error.
I have double checked the behavior with WLAN, this is ok and works well.
Thanks for your help.
Bye Albi
Hi Renzo,
have you alredy found why the user login does not work?
Regards Albi
Hi Albi,
I test It, and It’s working for me. Sorry, I can’t reproduce the issue.
Bye Renzo
Hi Renzo,
the FTP-server now works in my project. Reason was, the loop did last too long.
Thanks a lot.
Bye Albi
Thanks, Albi, for the feedback.
Hi Renzo….
I have try it using ESP32 with SD Card. When connect it with Filezilla, the FTP Server have been successfully directory listing, but when transfer the file from local PC to FTP Server is failed with message error “Transfer connection interrupted: ECONNABORTED – Connection aborted” & “File transfer failed”. So can you assist me to solve it ? Thank you
For your information, I have changed #define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SPIFFS with #define DEFAULT_STORAGE_TYPE_ESP32 STORAGE_SD in FtpServerKey.h file
Hi Fikry,
please open a forum topic and post your code.
We try to help you.
Bye Renzo
Dear Renzo,
Is there a fuction in this library that I can use for detecting a connection?
Now my program is waiting for 2 minutes for an incoming connection, if there is one then I have the remaining time within the 2 minutes timeframe then the code shuts down the connection and proceeds to the next phase.
I need a solution for detecting a connection which “catches” the call then the time limit can be erased and finally the user’s disconnection pushes forward the code and not running out of the timeframe.
Thanks for your help!
Norbert
Hi Norbert,
you can add a callback like so
and intercept some type of events
Bye Renzo
Hi Renzo,
Is it exist a way to configure the type of file system to be use without modify the FtpServerKey.h file anytime ? I use the ftpserver in various projects with SD_card or SPIFFS. It is boring to change anytime the #define in the library file each time I switch from a project using SPIFFS to an other using a SD card.
I tried to set the #define at the top of my sketch but it continue to use the value defined in the FtpServerKey.h file.
If i place in comment the #define in the FtpServerKey.h file, the compilation fail as the compiler not found the definition in the top of sketch.
Have you an idea ?
Thanks for your help !
Cheers
Hi,
no, at this moment no.
I think about that in the future releases.
Renzo
Hi Renzo,
thanks for the great library, but I have two Problems with esp8266:
1. transferring a file from SD to PC results in an empty file on the PC (flash to PC works well)
2. can I switch the up-/downloads from SD/PC to flash/PC without changing the FtpServerKey.h?
Hi Uli,
for the first problem, try to check the FTP client setting as described in the article,
for the second point, no, it isn’t possible; the server points to only one FS at a time.
Bye Renzo
Thanks Renzo,
I think the FTP client settings are ok because;
ESP32 – delete, uoload download are ok
ESP8266 – delete, uload are ok, download ends with an empty file on the PC
for the secon problem: is it possible to set the FS from the sketch instead of the :h file? I don’t need both FS in parallel.
Azz.. I must check the esp8266 version.
No, the second problem is that It’s not directly settable; try to add It before the include.
Bye Renzo
Hi All,
I’m experiencing the same problem as “Uli K”, downloading files from the SD CARD are empty. Has anyone found a solution please?
Thanks.
Hi, I have a problem when ipcam connect to my ftp:
*****************************************************************************
18:11:53.970 -> PASS OK: 0
18:11:53.970 -> Authentication Ok. Waiting for commands.
18:11:53.970 -> Command Old: 4 Transfer Old: 0 Data Old: 0
18:11:53.970 -> Command : 5 Transfer : 0 Data : 0
18:11:54.042 -> -P-W-D-
18:11:54.085 -> Command is: PWD
18:11:54.119 -> -C-W-D- -/-
18:11:54.193 -> Command is: CWD
18:11:54.225 -> -C-W-D- -.-/-T-e-s-t-
18:11:54.337 -> Command is: CWD
18:11:54.337 -> utf8_strlen7
18:11:54.378 -> PATH –> /./Test …NOT EXIST!
18:11:54.409 -> -P-W-D-
18:11:54.456 -> Command is: PWD
18:11:54.499 -> -C-W-D- -T-e-s-t-
18:11:54.611 -> Command is: CWD
18:11:54.611 -> utf8_strlen5
18:11:54.611 -> PATH –> /Test …EXIST!
18:11:54.646 -> -C-W-D- -.-/-T-e-s-t-
18:11:54.750 -> Command is: CWD
18:11:54.750 -> utf8_strlen12
18:11:54.750 -> PATH –> /Test/./Test …NOT EXIST!
18:11:54.834 -> -Q-U-I-T-
18:11:54.867 -> Command is: QUIT
*****************************************************************************
This ” .-/-” is the root of the disk, but server think that it is the folder.
Hi Anton,
do you have the same problem with the previous version of the library?
Bye Renzo
v 2.1.8
and 2.1.7 too
is there a way to fix the error?
Hi Anton,
these weeks I’m too busy. I try to check It soon.
Bye Renzo
Can you find time for check this error?
Hi Renzo,
thanks for the great library.
I use the library with an ESP32 and SD.
When transferring files from the ESP32 to the PC, they all have the date 01/01/1970 00:00:00.
To solve the problem, I added the following to FtpServer.cpp starting at line 1649
so that the correct date and time is transferred.
Can you add this permanently to the library so that I don’t always have to adjust it after an update?
Bye Jens
Hi Jens,
do you test this code with esp32 and esp8266?
Bye Renzo
Hi Renzo,
with a ESP32.
I have not tested the code with any other board.
The code I added works fine an a ESP32.
Your original code is: line 1649
// struct tm * timeinfo;
strcpy(dtStr, “19700101000000”);
Bye Jens
Thank you for your library for ESP32. I use it and really like it. But in the latest update 2.1.8, the FTP server stopped working, something is wrong with the password. Rolled back to 2.1.6 – everything worked. 2.1.7 – I haven’t tried it. 2.1.8 – does not work.
Hi Aleksandr,
which connection and storage do you use?
Bye RM
Hi Renzo,
thanks very much for sharing this library. I tried it with ESP32S3 (16MB Flash, custom partitioning: “littlefs,data,littlefs,0x810000,0x7E0000,”) and LittleFS. I have set hopefully everything in Arduino and FileZilla according your web page but I can’t make it working. I ended at FileZilla point “Retrieving directory listing…” and after 20s I get connection timeout error and failed to retrieve directory listing. Did I forget something?
Here is Arduino output:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x10f0
load:0x403c8700,len:0x4
load:0x403c8704,len:0xbec
load:0x403cb700,len:0x2fb8
entry 0x403c88ac
LittleFS mounted
WiFi-event: 9 = WiFi interface ready
WiFi-event: 11 = WiFi client started
WiFi-event: 13 = Connected to access point
WiFi-event: 16 = Obtained IP address: 192.168.1.159
NOT ANONYMOUS
admin
HTTP server started
Command Old: 0 Transfer Old: 0 Data Old: 0
Command : 1 Transfer : 0 Data : 0
Ftp server waiting for connection on port 21
Command Old: 1 Transfer Old: 0 Data Old: 0
Command : 2 Transfer : 0 Data : 0
Client connected!
FTP: Connected!
Command Old: 2 Transfer Old: 0 Data Old: 0
Command : 3 Transfer : 0 Data : 0
-U-S-E-R- -a-d-m-i-n–
Command is: USER
USER: admin admin
Command Old: 3 Transfer Old: 0 Data Old: 0
Command : 4 Transfer : 0 Data : 0
-P-A-S-S- -a-d-m-i-n–
Command is: PASS
PASS: admin
PASS PARAM: admin
PASS OK: 0
Authentication Ok. Waiting for commands.
Command Old: 4 Transfer Old: 0 Data Old: 0
Command : 5 Transfer : 0 Data : 0
-O-P-T-S- -U-T-F-8- -O-N–
Command is: OPTS
200 OK, UTF8 ON
-P-W-D–
Command is: PWD
-T-Y-P-E- -I–
Command is: TYPE
-P-A-S-V–
Command is: PASV
IP: 192.168.1.159
Soft IP: 192.168.1.159
Connection management set to passive
Listening at 192.168.1.159:50009
Command Old: 5 Transfer Old: 0 Data Old: 0
Command : 5 Transfer : 0 Data : 1
FTP: Disconnected!
Here is FileZilla output:
Status: Connecting to 192.168.1.159:21…
Status: Connection established, waiting for welcome message…
Status: Plain FTP is insecure. Please switch to FTP over TLS.
Status: Logged in
Status: Retrieving directory listing…
Command: PWD
Response: 257 “/” is your current directory
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
Command: PASV
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
Status: Disconnected from server
Best regards,
Ivan
Hi Ivan,
Sorry for the late response. It seems that there are some problems accessing the data from the flash.
Check the flash access and recheck the configuration as the documentation says.
Bye Renzo