jmeter - 无法在 JMeter 中使用 SSH SFTP 采样器获取文件
问题描述
我是 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
解决方案
很可能您正坐在公司代理服务器后面,这是访问 Internet 甚至可能是Intranet资源所需的。
可以将JMeter 配置为使用企业代理,但是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()
参考:
推荐阅读
- promise - 无法在 Blazor 中收到承诺
- bash - 如何在 bash 中处理“找不到命令”
- python - 如何以编程方式关闭 matplotlib 窗口?
- vue.js - 如何在 Vue.js 中使用 codemirror 发送行号?
- javascript - 模块代码错误试图分离我的代码
- scala - 如何使用 Spark 中的 scala 将单个单元格中的数据提取到多个列中
- javascript - 使用 unshift() 添加数据时获得漂亮的 chart.js 动画?
- javascript - 如何在 Nativescript 和普通 JS 中禁用 iOS 捏缩放和双击缩放
- oop - 我们是否应该始终使用工厂而不是使用“new”关键字创建对象?
- jquery - 如何修复 jquery 滑块库中的不透明度