FTP上传问题 - 0字节转移 [英] FTP Upload Problem - 0 bytes transfered
问题描述
在我们的项目之一,我们正在使用Apache的FTP客户端API。
我得xml文件上传到FTP服务器,一个进程将不断轮询该服务器目录。因此,使用上传API,我上传与.TRANSFER扩展XML文件,并在成功上传完整的文件,该文件将被重命名为.xml文件。
In one of our project we are using Apache's FTP client APIs. I have to upload xml file to a FTP server, where a process will keep polling that server directory. So using the upload API, I am uploading the xml file with .TRANSFER extension, and after successfully uploading full file, the file will be renamed to .xml file.
我对着奇怪的问题是,有时文件的文件大小为0字节。但相同的文件有时完全被上传。当我看着日志文件时,发送的字节数只有0 KB。所以,我不知道可能是什么问题。
The weird problem I am facing was that, sometimes the file size of the file is 0 bytes. but the same file sometimes fully gets uploaded. When I looked at log file, the transfered bytes are 0 kb only. So I am not sure what could be the problem.
我使用的Linux服务器和Apache的公地的FTP客户端的API。
I am using linux server and Apache's commons's FTP client APIs.
任何调试提示和技巧会有所帮助。
Any debugging tips and tricks will be helpful.
问候,
SRINIVAS
Regards, Srinivas
推荐答案
我也遇到了这个而回。
我注意到,如果该文件是不是一定规模更大(这是174字节左右,对我来说),它没有得到正确传输。较小的文件最终被创建为零字节的文件。
I noticed that if the file was bigger than a certain size (it was 174 bytes or so for me), it did get transferred correctly. Smaller files ended up being created as zero byte files.
我相信这是在Apache的公共FTP code的错误。我固定它通过获取源代码,做了速战速决,并且我为我们的工作所产生的罐子。
I believe it is a bug in the Apache commons ftp code. I fixed it by getting the source and did a quick fix and the resulting jar that I built worked for us.
如果我记得正确的修复,我正被用于在下议院FTP code传输插座上禁用Nagle算法与socket.setTcpNoDelay(假)。
If I remember the fix right, I disabled Nagle's algorithm with socket.setTcpNoDelay(false) on the socket that was being used for the transfer in the commons ftp code.
这篇关于FTP上传问题 - 0字节转移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!