如何使用 SSL/TLS 设置 JMeter TCP 采样器?
How to setup JMeter TCP Sampler with SSL/TLS?
在 JMeter 中使用 SSL 设置 HTTPS 非常简单,但相同的设置不适用于 TCP 采样器,有任何指示吗?
目前 JMeter TCP Sampler 不支持 SSL 协议,您需要编写自己的实现或考虑改用 JSR223 Sampler。
创建 SSL TCP 连接的参考代码
import org.apache.jmeter.util.JsseSSLManager;
import org.apache.jmeter.util.SSLManager;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
int your_app_port = 1234;
String your_app_host = "localhost";
JsseSSLManager sslManager = (JsseSSLManager) SSLManager.getInstance();
SSLSocketFactory sslsocketfactory = sslManager.getContext().getSocketFactory();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(your_app_host, your_app_port);
//do what you need with the SSL socket here
参考文献:
- how to do ssl socket programming
- SSLSocket
- Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For!
在 JMeter 中使用 SSL 设置 HTTPS 非常简单,但相同的设置不适用于 TCP 采样器,有任何指示吗?
目前 JMeter TCP Sampler 不支持 SSL 协议,您需要编写自己的实现或考虑改用 JSR223 Sampler。
创建 SSL TCP 连接的参考代码
import org.apache.jmeter.util.JsseSSLManager;
import org.apache.jmeter.util.SSLManager;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
int your_app_port = 1234;
String your_app_host = "localhost";
JsseSSLManager sslManager = (JsseSSLManager) SSLManager.getInstance();
SSLSocketFactory sslsocketfactory = sslManager.getContext().getSocketFactory();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(your_app_host, your_app_port);
//do what you need with the SSL socket here
参考文献:
- how to do ssl socket programming
- SSLSocket
- Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For!