Getting HTTPS setup in JMeter with SSL is pretty straight forward but same setup is not working for TCP Sampler, any pointer?
Asked
Active
Viewed 2,503 times
2
-
Just for curiosity, why do you need to use the TCP Sampler if HTTP(S) works fine? You'll probably have to implement your own TCP sampler client. – Masud Jahan Oct 04 '16 at 04:03
-
it's for two different application but a learning stepping stone for me – ZeTradr Oct 04 '16 at 04:56
1 Answers
2
For the moment JMeter TCP Sampler doesn't support SSL protocol, you will either need to write your own implementation or consider switching to JSR223 Sampler instead.
Reference code to create SSL TCP connection
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
References: