代码中可以正常连接到FTP,也能进入目录下,但是无法获取文件,后台输出如下211-Status for user FTP_CDHK from 114.255.71.181: Stored 0 files, 0 kBytes Retrieved 0 files, 0 kBytes 211 End of status.true 211-Status for user FTP_CDHK from 114.255.71.181: Stored 0 files, 0 kBytes Retrieved 0 files, 0 kBytes 211 End of status.
后台的错误 java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at java.net.Socket.<init>(Socket.java:375) at java.net.Socket.<init>(Socket.java:189) at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:206) at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:592) at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2545) at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2519) at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2275) at com.bireturn.cames.ftpTask.FtpForEmail.downloadAndEmail(FtpForEmail.java:48) at com.bireturn.cames.ftpTask.FtpForEmail.main(FtpForEmail.java:143) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Exception in thread "main" java.lang.NullPointerException at com.bireturn.cames.ftpTask.FtpForEmail.downloadAndEmail(FtpForEmail.java:80) at com.bireturn.cames.ftpTask.FtpForEmail.main(FtpForEmail.java:143) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
listFiles(String pathname) Using the default system autodetect mechanism, obtain a list of file information for the current working directory or for just a single file.listNames() Obtain a list of filenames in the current working directory This information is obtained through the NLST command.官方文档是这么写的,不知道为什么你要用listNames,明显第一个靠谱嘛
Stored 0 files, 0 kBytes
Retrieved 0 files, 0 kBytes
211 End of status.true
211-Status for user FTP_CDHK from 114.255.71.181:
Stored 0 files, 0 kBytes
Retrieved 0 files, 0 kBytes
211 End of status.
使用IE浏览器登录后一直卡在跳转。
JAVA中使用的是org.apache.commons.net这个包,代码是绝对没有问题的,可以连接成功并进入文件夹
但是无法读取文件夹下的文件。
ftp用户权限是没有问题的。
Stored 0 files, 0 kBytes
Retrieved 0 files, 0 kBytes但是使用FileZilla客户端可以正常下载
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:189)
at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:206)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:592)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2545)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2519)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2275)
at com.bireturn.cames.ftpTask.FtpForEmail.downloadAndEmail(FtpForEmail.java:48)
at com.bireturn.cames.ftpTask.FtpForEmail.main(FtpForEmail.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Exception in thread "main" java.lang.NullPointerException
at com.bireturn.cames.ftpTask.FtpForEmail.downloadAndEmail(FtpForEmail.java:80)
at com.bireturn.cames.ftpTask.FtpForEmail.main(FtpForEmail.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
但是谷歌是正常的
Using the default system autodetect mechanism, obtain a list of file information for the current working directory or for just a single file.listNames()
Obtain a list of filenames in the current working directory This information is obtained through the NLST command.官方文档是这么写的,不知道为什么你要用listNames,明显第一个靠谱嘛
1.检查一下你call的API,搜索一下是否有人讨论过这样的bug
2.你找个抓包工具抓一下chrome的,然后再比比你java的