我是JMeter的新手,正在尝试连接sftp服务器。我正在粘贴JMeter的日志。我不确定如果用户名或密码有问题,为什么我会收到此错误,所以我可以使用FileZilla中的相同详细信息。请帮帮我。
2019-01-01 20:23:07,423 INFO o.a.j.e.StandardJMeterEngine: Running the test!
2019-01-01 20:23:07,424 INFO o.a.j.s.SampleEvent: List of sample_variables: []
2019-01-01 20:23:07,425 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
2019-01-01 20:23:07,581 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : FTP Users
2019-01-01 20:23:07,581 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group FTP Users.
2019-01-01 20:23:07,581 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
2019-01-01 20:23:07,581 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 perThread=1000.0 delayedStart=false
2019-01-01 20:23:07,582 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2019-01-01 20:23:07,582 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
2019-01-01 20:23:07,583 INFO o.a.j.t.JMeterThread: Thread started: FTP Users 1-1
2019-01-01 20:23:07,587 ERROR o.a.j.p.s.s.AbstractSSHSampler: SSH connexion error
com.jcraft.jsch.JSchException: java.net.UnknownHostException: sftp://xx.x.x.xx
答案 0 :(得分:1)
很可能您坐在公司proxy server的后面,这是访问Internet甚至Intranet资源所必需的。
可以configure JMeter to use corporate proxy,但是SSH Sampler既不遵守JMeter代理配置,也不提供其自己的代理设置。
因此,目前我能想到的唯一方法是在JSR223 Sampler
中编写与SSH相关的代码示例代码如下:
def jsch = new com.jcraft.jsch.JSch()
def session = jsch.getSession('your_username', 'your_host', 22) //replace 22 with your port for custom SSH server ports
def proxy = new com.jcraft.jsch.ProxyHTTP("your_corporate_proxy_host", 3128) // replace 3128 with your corporate proxy port
proxy.setUserPasswd('corporate_proxy_username', 'corporate_proxy_password')
session.setProxy(proxy)
session.setConfig("StrictHostKeyChecking", "no")
session.setPassword('your_ssh_password')
session.connect()
def channel = session.openChannel("sftp")
((com.jcraft.jsch.ChannelSftp) channel).get('remote_file', 'local_file')
session.disconnect()
参考文献: