0
votes
  1. I tried posting data to influx DB from post man and JMeter HTTP Sampler and I was able to post the data successfully.
  2. When I tried mimicking the same calls via 'JSR223 Listener' with the help of BeanShell script, I received an error like below,

avax.script.ScriptException: Sourced file: eval stream : Typed variable declaration : Method Invocation httpClient.execute : at Line: 20 : in file: eval stream : httpClient .execute ( httpPost )

Called from method: write : at Line: 54 : in file: eval stream : write ( queryString ) Target exception: java.net.ConnectException: Connection timed out: connect in eval stream at line number 20

Can anyone please suggest me why this is causing the error and should do any modification in the script developed or any imports missing?

1

1 Answers

0
votes

Looking into Connection timed out message your code works more of less fine, it just fails to establish connection with the target server, it is hard to say anything without seeing it (blind shot: are you running your test via corporate proxy? If yes, your code won't respect JMeter proxy settings, you will need to perform a separate configuration)

In the meantime a couple of recommendations:

  1. Switch to Groovy language
  2. Tick Cache compiled script if available box

    Groovy listener configuration

Groovy is a much better scripting choice than Beanshell as it is capable of compiling scripts into bytecode while Beanshell interpreter evaluates it each time it calls so Groovy will perform be much faster (assuming the same code). Besides Groovy has better Java support and provides some extra features on top. See Groovy is the New Black article for more details.