ssltcpjmeterjmeter-plugins

How to setup JMeter TCP Sampler with SSL/TLS?


Getting HTTPS setup in JMeter with SSL is pretty straight forward but same setup is not working for TCP Sampler, any pointer?


Solution

  • 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: