-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload with lftp not working when TLS is used #470
Comments
Hi, I just tested using lftp installed locally instead of in Docker and I cannot replicate
In the logs I always have this
P.S. I used SFTPGo instead of your reproducer |
Thank you @drakkan . In my tests I always disconnected and re-connected between each attempt; however, I can reproduce it even without re-conencting:
On the server:
It did it correctly only the first time, then writtenBytes=0. Maybe it's something wrong with my basic implementation? I did nothing fancy indeed 🤷♂️ |
Just to be sure it was not something related to my FS, I changed this line:
to a more generic
I can still reproduce it, even if it seems to be less frequent:
On the server:
|
@ale-rinaldi I'm not sure, in SFTPGo I don't use afero but a custom implementation. I'll try to find some time to test using afero with your reproducer but it might take a while, sorry. I think ftpserver uses afero, can you reproduce the reported issue also using this server? Thank you |
Hello, I can actually reproduce it with ftpserver, even if it's even more rare. My ftpserver config: {
"version": 1,
"listen_address": ":21",
"tls": {
"server_cert": {
"cert": "cert.pem",
"key": "key.pem"
}
},
"accesses": [
{
"user": "test",
"pass": "test",
"fs": "os",
"params": {
"basePath": "/tmp"
}
}
],
"passive_transfer_port_range": {
"start": 2122,
"end": 2130
}
} From lftp:
From ftpserver:
It happened literally 2 times out of many attempts. I really can't understand... |
hmm weird, I should try harder to replicate the problem against SFTPGo too. Does it happen with other clients or is it specific to lftp? |
@drakkan I don't have this issue with any other client; I replaced lftp uploads with |
This is definitely an odd behavior, which is worth looking into. I'll try to find some time in the next weeks to look into it. |
Thank you @fclairamb , if I can be of any help with further details or testing please let me know. Have a good day! |
I can't reproduce even with ftpserver:
I have lftp installed locally and not in Docker
not sure if this makes any difference (it is compiled against glibc and not musl libc) |
I'm sorry it's so difficult to reproduce, I don't think it's related to musl. In my production setup, when I noticed the issue, the Golang built executable is running directly on the server with Ubuntu 22.04, while the lftp client is on another physical machine on a Debian-based Docker container. The production executable does something more on file close than the example I posted (uploads it to S3 and writes some database entries). On this setup, the upload with lftp fails literally every time, with a 0-byte result. For the test, I'm executing the simpler code I posted with I will try to simplify my testing and do it on a physical PC with a clean setup, then I'll introduce some sleep to see how it affects. I'll keep you updated. Meanwhile, thanks for your interest on this. |
Hello,
I recently used ftpserverlib to migrate an old setup based on PureFTP. Everything is good except some scripts based on lftp that began to upload 0-byte files without any error.
Doing some tests, I noticed that this happens only when TLS is involved, while there seems to be no issue on a plain connection.
I have a minimal reproducible step-by-step example:
Create an empty folder and enter it
Run
go mod init test
Create a self-signed certificate
Run
go mod tidy
Run with
sudo go run .
Run a Docker container with Alpine, on host network so that 127.0.0.1 is reachable:
8: Run those commands:
On lftp side I see: "5 bytes transferred".
On ftpserverlib I see: "level=DEBUG msg="Stream copy finished" clientId=1 writtenBytes=0".
The file /tmp/test.txt on the host has 0 bytes length.
This actually does not always happen, sometimes it fails on first attempt and sometimes after 4 or 5 attempts.
Unfortunately, I'm unable to track down what this depends on or debug it. I'm not blaming ftpserverlib, it may be an lftp problem. I hope someone may point me to the right direction.
Thank you
The text was updated successfully, but these errors were encountered: