0

I have developed a proxy service using ballerina language by referring the following [1] and [2]. It works perfectly fine. Now I want to run a load test via JMeter. That is JMeter should be configured in a such a way that the http request to a particular resource should be passed through the proxy service (In 1 mentioned above it is a client program and now I want to send the request via the JMeter). How to do it? How to configure the JMeter?

5 Answers 5

1

You can find proxy configuration for JMeter on "Advanced" tab of the HTTP Request sampler where you can specify host, port and credentials

JMeter Proxy Server for HTTP Request

If you have > 1 HTTP Request sampler you can set proxy for them all in one place using HTTP Request Defaults configuration element, this way you can set up default configuration for all HTTP Request samplers in HTTP Requests Defaults scope so the configuration will be applied to all samplers where the relevant fields are empty.

JMeter Proxy for HTTP Request

3

Rather than having a client with the main function, you can have a service for that. For example,

import ballerina/http;
import ballerina/io;

endpoint http:Listener passthroughEP {
    port:8243
};

endpoint http:Client clientEP {
    url:"http://localhost:9218",
    proxy: {
        host:"localhost",
        port:9219
    }
};

@http:ServiceConfig {basePath:"/services/EchoProxy"}
service<http:Service> passthroughService bind passthroughEP {
    @http:ResourceConfig {
        methods:["POST"],
        path:"/"
    }
    passthrough(endpoint outboundEP, http:Request clientRequest) {
        var resp = clientEP -> forward("/proxy/server", clientRequest);
        match resp {
           error err => io:println(err.message);
           http:Response response => {
              match (response.getTextPayload()) {
                 error payloadError => io:println(payloadError.message);
                 string res => {
                    io:println(res);
                    _ = outboundEP->respond(res);   
                 }    
              }
           }
        }
    }
}

In here you have a listener endpoint which binds to the passthrough service. You can invoke this passthrough service from Jmeter (Give the URL of this service in Jmeter). Once the service is invoked it will forward the request to the proxy server.

2

Additionally, you can run proxy_server.bal which you are referring as 2 and configure the JMeter in order to send requests via Proxy Server as follows.

jmeter -H my.proxy.server -P 8000 -u username -a password -N localhost

Please refer this for more information on JMeter configuration.

1

Turn your main program into an HTTP service first. In order to achieve the proxy behaviour, use forward client action to forward the inbound request to the backend service. Then you can perform the load test by invoking the the resource via JMeter request.

0

Answers provided by both ldclakmal and Dmithri T implies the same and solved my problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .