1.对此感到抱歉,但只是为了确保:您是否确保 FTP 连接手动成功,即不是通过 jmeter 脚本中的 FTP 请求,而是通过控制台/telnet 连接或任何 FTP 客户端实用程序?
2.FTP 被动模式
可能的原因:
由于您的 FTP 请求在 PASV 命令执行期间失败,可以假设根本原因是您的 ftp 服务器不支持被动模式,而 jmeter 的 FTP 请求默认使用被动模式。
为了确保从控制台连接到 ftp 后尝试切换到被动模式,
例如
telnet your.ftp.server.url 21
USER yourusername
PASS yourpassword
PASV
or
ftp -d your.ftp.server.url
USER yourusername
PASS yourpassword
passive
或使用任何可以选择连接模式(主动/被动)的 ftp 客户端实用程序。
如果在此过程中出现同样的问题 - 好吧,问题是您的 ftp 服务器不支持 FTP 请求使用的被动模式。
参见例如this http://www.onkarjoshi.com/blog/128/understand-ftp-passive-pasv-and-active-modes/解释两种模式的差异。
可能的解决方案:
As per jmeter源 http://svn.apache.org/repos/asf/jmeter/trunk/src/protocol/ftp/org/apache/jmeter/protocol/ftp/sampler/FTPSampler.java:
ftp.enterLocalPassiveMode();
默认情况下使用切换到被动模式,并且无法在外部设置模式FTP 请求配置屏幕 http://jmeter.apache.org/usermanual/component_reference.html#FTP_Request.
但您可以自己实现 ftp 请求,避免使用 FTP 请求。
您可以使用FTP客户端 https://commons.apache.org/net/api-3.1/org/apache/commons/net/ftp/FTPClient.html实现自阿帕奇共享网 https://commons.apache.org/net/并编写 ftp 连接脚本BeanShell 采样器 http://jmeter.apache.org/usermanual/component_reference.html#BeanShell_Sampler.
非常简化,这可能看起来像:
import org.apache.commons.net.ftp.*;
FTPClient client = new FTPClient();
client.setDataTimeout(3600000);
client.connect(ftpHost,ftpPort);
client.login(userName, userName);
client.setFileType(FTPClient.BINARY_FILE_TYPE);
...
// FTPClient uses 'active mode' by default
if (ftp_passive_mode) {
client.enterLocalPassiveMode();
} else {
client.enterLocalActiveMode();
}
...
client.logout();
client.disconnect();
也许我也错了,你的问题的原因隐藏在另一个地方。
希望这将帮助您诊断并解决您的问题。