You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Adam Ploverall <ad...@googlemail.com> on 2011/01/27 12:44:36 UTC

Handling of java.net.SocketTimeoutException errors

Hello

I have been trying to build some conditional logic into my tests, and
have been trying the IF CONTROLLER, RESPONSE ASSERTION and BEAN SHELL
ASSERTIONs.  Sometimes, my HTTP SAMPLER gets a timeout response like:

   java.net.SocketTimeoutException: connect timed out

   or

   java.net.SocketTimeoutException: Read timed out

These might be due to lack of resources, or the tested site being
down.  But it seems the HTTP SAMPLER is setting these:

   Error Count: 1
   Response code: Non HTTP response code: java.net.SocketTimeoutException

and I can't work out how to suppress this, and say skip a subsequent
MAILER VISUALIZER.

In a BEAN SHELL ASSERTION, I have tried:

   if (ResponseCode.equals(null)==false && ResponseCode.equals("Non
HTTP response code: java.net.SocketTimeoutException")==false)  {

   ...

   }

but the sampler seems to be skipped due to the HTTP SAMPLER error.  If
I use a RESPONSE ASSERTION, I can ignore the status code (checkbox),
but then have little control about what happens next.

My aim is to do something like this:

1. Do an HTTP request
1a) 5 min timer delay (Constant Timer)

2. If the response has a status code and content (else skip to 3.):
2a) do some other response assertion tests on the headers and content
2b) use the mailer visualiser to alert on any failure (0/0 setting)
2c) Skip to 4.

3. If a java.net.SocketTimeoutException occurs
3a) use the mailer visualiser to alert on two failures (1/0 setting)
3b) reset the failure count to 0 if we haven't had another failure in X minutes
3c) Continue to 4

4. Continue indefinite loop

In other words, treat the 3s with less priority.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Handling of java.net.SocketTimeoutException errors

Posted by Adam Ploverall <ad...@googlemail.com>.
Sebb

Thank you so much for your time!

Maybe the last_sample_ok issue was confusing me, but I've now got
something to work with.

Adam

On 27 January 2011 17:19, sebb <se...@gmail.com> wrote:
> On 27 January 2011 16:49, Adam Ploverall <ad...@googlemail.com> wrote:
>> Sebb
>>
>> Thank you for your perceptive answer.  Yes, I was wrong to say the
>> BEAN SHELL ASSERTION script was being skipped.
>>
>> I have:
>>
>> Thread Group (1/0/1)
>> + HTTP Cache Manager (clear cache)
>> + HTTP Cookie Manager (clear cookies)
>> + Simple Controller
>> ++ HTTP Request
>> +++HTTP Header Manager (host, accept, useragent, etc)
>> ++Bean Shell Assertion
>> ++ Assertion Results
>> + View Results Tree
>> + Mailer Visualizer
>>
>> The BEAN SHELL ASSERTION now contains only:
>>
>>   print("Start of script 27b");
>>   print(vars.get("JMeterThread.last_sample_ok"));
>>   print( ResponseCode);
>>
>> With a valid tested server port:
>>
>>  Start of script 27b
>>  true
>>  200
>
> OK
>
>> and we have success.
>>
>> When changing the HTTP request to an invalid port (just to fake the test):
>>
>>  Start of script 27b
>>  true
>>  Non HTTP response code: java.net.SocketTimeoutException
>
> That may be a bug - not sure why last_sample_ok is true here.
> [Also the response code should probably be numeric]
>
>> and the Mailer Visualizer sees an error (failure).  The sampler result is:
>
> That's because SampleResult.isSuccessful() is false
>
>>
>>   Thread Name: *************
>>   Sample Start: 2012-04-08 03:40:54 BST
>>   Load time: 5005
>>   Latency: 0
>>   Size in bytes: 1577
>>   Sample Count: 1
>>   Error Count: 1
>>   Response code: Non HTTP response code: java.net.SocketTimeoutException
>>   Response message: Non HTTP response message: connect timed out
>>
>>  Response headers:
>>
>>   HTTPSampleResult fields:
>>   ContentType:
>>   DataEncoding: null
>>
>> So, I suppose my simpler question is, how would I conditionally branch
>> on the HTTP Request sampler error, and only do other assertion tests
>> and email if a non null status code is returned?  I'm happy to do this
>> in the Bean Shell script, if it isn't possible with the standard
>> Jmeter components.
>
> This boils down to how to distinguish the different HTTP sample results.
>
> SInce last_sample_ok is not being set (I think that's a bug), just
> check SampleResult.isSuccessful() instead.
>
> For example,
>
> vars.put("OK",String.valueOf(SampleResult.isSuccessful()));
>
> ...
>
> If Condition = ${OK}, Interpret Condition as Variable Expression? = true
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Handling of java.net.SocketTimeoutException errors

Posted by Adam Ploverall <ad...@googlemail.com>.
Thank you for checking these, and updating the thread for everyone's
future reference.

Adam

On 27 January 2011 17:36, sebb <se...@gmail.com> wrote:
> On 27 January 2011 17:19, sebb <se...@gmail.com> wrote:
>> On 27 January 2011 16:49, Adam Ploverall <ad...@googlemail.com> wrote:
>>> Sebb
>>>
>>> Thank you for your perceptive answer.  Yes, I was wrong to say the
>>> BEAN SHELL ASSERTION script was being skipped.
>>>
>>> I have:
>>>
>>> Thread Group (1/0/1)
>>> + HTTP Cache Manager (clear cache)
>>> + HTTP Cookie Manager (clear cookies)
>>> + Simple Controller
>>> ++ HTTP Request
>>> +++HTTP Header Manager (host, accept, useragent, etc)
>>> ++Bean Shell Assertion
>>> ++ Assertion Results
>>> + View Results Tree
>>> + Mailer Visualizer
>>>
>>> The BEAN SHELL ASSERTION now contains only:
>>>
>>>   print("Start of script 27b");
>>>   print(vars.get("JMeterThread.last_sample_ok"));
>>>   print( ResponseCode);
>>>
>>> With a valid tested server port:
>>>
>>>  Start of script 27b
>>>  true
>>>  200
>>
>> OK
>>
>>> and we have success.
>>>
>>> When changing the HTTP request to an invalid port (just to fake the test):
>>>
>>>  Start of script 27b
>>>  true
>>>  Non HTTP response code: java.net.SocketTimeoutException
>>
>> That may be a bug - not sure why last_sample_ok is true here.
>
> Just realised that this is because the variable is only set once all
> the Assertions have been run, as it depends on the Assertions.
>
> So the variable is not accurate whilst assertions are being processed,
> nor PostProcessors since they run before Assertions.
>
> You could use a Listener instead and the variable will be OK then.
>
>> [Also the response code should probably be numeric]
>
> Also not true...
>
>>> and the Mailer Visualizer sees an error (failure).  The sampler result is:
>>
>> That's because SampleResult.isSuccessful() is false
>>
>>>
>>>   Thread Name: *************
>>>   Sample Start: 2012-04-08 03:40:54 BST
>>>   Load time: 5005
>>>   Latency: 0
>>>   Size in bytes: 1577
>>>   Sample Count: 1
>>>   Error Count: 1
>>>   Response code: Non HTTP response code: java.net.SocketTimeoutException
>>>   Response message: Non HTTP response message: connect timed out
>>>
>>>  Response headers:
>>>
>>>   HTTPSampleResult fields:
>>>   ContentType:
>>>   DataEncoding: null
>>>
>>> So, I suppose my simpler question is, how would I conditionally branch
>>> on the HTTP Request sampler error, and only do other assertion tests
>>> and email if a non null status code is returned?  I'm happy to do this
>>> in the Bean Shell script, if it isn't possible with the standard
>>> Jmeter components.
>>
>> This boils down to how to distinguish the different HTTP sample results.
>>
>> SInce last_sample_ok is not being set (I think that's a bug), just
>
> Not a bug - see above.
>
>> check SampleResult.isSuccessful() instead.
>>
>> For example,
>>
>> vars.put("OK",String.valueOf(SampleResult.isSuccessful()));
>>
>> ...
>>
>> If Condition = ${OK}, Interpret Condition as Variable Expression? = true
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Handling of java.net.SocketTimeoutException errors

Posted by sebb <se...@gmail.com>.
On 27 January 2011 17:19, sebb <se...@gmail.com> wrote:
> On 27 January 2011 16:49, Adam Ploverall <ad...@googlemail.com> wrote:
>> Sebb
>>
>> Thank you for your perceptive answer.  Yes, I was wrong to say the
>> BEAN SHELL ASSERTION script was being skipped.
>>
>> I have:
>>
>> Thread Group (1/0/1)
>> + HTTP Cache Manager (clear cache)
>> + HTTP Cookie Manager (clear cookies)
>> + Simple Controller
>> ++ HTTP Request
>> +++HTTP Header Manager (host, accept, useragent, etc)
>> ++Bean Shell Assertion
>> ++ Assertion Results
>> + View Results Tree
>> + Mailer Visualizer
>>
>> The BEAN SHELL ASSERTION now contains only:
>>
>>   print("Start of script 27b");
>>   print(vars.get("JMeterThread.last_sample_ok"));
>>   print( ResponseCode);
>>
>> With a valid tested server port:
>>
>>  Start of script 27b
>>  true
>>  200
>
> OK
>
>> and we have success.
>>
>> When changing the HTTP request to an invalid port (just to fake the test):
>>
>>  Start of script 27b
>>  true
>>  Non HTTP response code: java.net.SocketTimeoutException
>
> That may be a bug - not sure why last_sample_ok is true here.

Just realised that this is because the variable is only set once all
the Assertions have been run, as it depends on the Assertions.

So the variable is not accurate whilst assertions are being processed,
nor PostProcessors since they run before Assertions.

You could use a Listener instead and the variable will be OK then.

> [Also the response code should probably be numeric]

Also not true...

>> and the Mailer Visualizer sees an error (failure).  The sampler result is:
>
> That's because SampleResult.isSuccessful() is false
>
>>
>>   Thread Name: *************
>>   Sample Start: 2012-04-08 03:40:54 BST
>>   Load time: 5005
>>   Latency: 0
>>   Size in bytes: 1577
>>   Sample Count: 1
>>   Error Count: 1
>>   Response code: Non HTTP response code: java.net.SocketTimeoutException
>>   Response message: Non HTTP response message: connect timed out
>>
>>  Response headers:
>>
>>   HTTPSampleResult fields:
>>   ContentType:
>>   DataEncoding: null
>>
>> So, I suppose my simpler question is, how would I conditionally branch
>> on the HTTP Request sampler error, and only do other assertion tests
>> and email if a non null status code is returned?  I'm happy to do this
>> in the Bean Shell script, if it isn't possible with the standard
>> Jmeter components.
>
> This boils down to how to distinguish the different HTTP sample results.
>
> SInce last_sample_ok is not being set (I think that's a bug), just

Not a bug - see above.

> check SampleResult.isSuccessful() instead.
>
> For example,
>
> vars.put("OK",String.valueOf(SampleResult.isSuccessful()));
>
> ...
>
> If Condition = ${OK}, Interpret Condition as Variable Expression? = true
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Handling of java.net.SocketTimeoutException errors

Posted by sebb <se...@gmail.com>.
On 27 January 2011 16:49, Adam Ploverall <ad...@googlemail.com> wrote:
> Sebb
>
> Thank you for your perceptive answer.  Yes, I was wrong to say the
> BEAN SHELL ASSERTION script was being skipped.
>
> I have:
>
> Thread Group (1/0/1)
> + HTTP Cache Manager (clear cache)
> + HTTP Cookie Manager (clear cookies)
> + Simple Controller
> ++ HTTP Request
> +++HTTP Header Manager (host, accept, useragent, etc)
> ++Bean Shell Assertion
> ++ Assertion Results
> + View Results Tree
> + Mailer Visualizer
>
> The BEAN SHELL ASSERTION now contains only:
>
>   print("Start of script 27b");
>   print(vars.get("JMeterThread.last_sample_ok"));
>   print( ResponseCode);
>
> With a valid tested server port:
>
>  Start of script 27b
>  true
>  200

OK

> and we have success.
>
> When changing the HTTP request to an invalid port (just to fake the test):
>
>  Start of script 27b
>  true
>  Non HTTP response code: java.net.SocketTimeoutException

That may be a bug - not sure why last_sample_ok is true here.
[Also the response code should probably be numeric]

> and the Mailer Visualizer sees an error (failure).  The sampler result is:

That's because SampleResult.isSuccessful() is false

>
>   Thread Name: *************
>   Sample Start: 2012-04-08 03:40:54 BST
>   Load time: 5005
>   Latency: 0
>   Size in bytes: 1577
>   Sample Count: 1
>   Error Count: 1
>   Response code: Non HTTP response code: java.net.SocketTimeoutException
>   Response message: Non HTTP response message: connect timed out
>
>  Response headers:
>
>   HTTPSampleResult fields:
>   ContentType:
>   DataEncoding: null
>
> So, I suppose my simpler question is, how would I conditionally branch
> on the HTTP Request sampler error, and only do other assertion tests
> and email if a non null status code is returned?  I'm happy to do this
> in the Bean Shell script, if it isn't possible with the standard
> Jmeter components.

This boils down to how to distinguish the different HTTP sample results.

SInce last_sample_ok is not being set (I think that's a bug), just
check SampleResult.isSuccessful() instead.

For example,

vars.put("OK",String.valueOf(SampleResult.isSuccessful()));

...

If Condition = ${OK}, Interpret Condition as Variable Expression? = true

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Handling of java.net.SocketTimeoutException errors

Posted by Adam Ploverall <ad...@googlemail.com>.
Sebb

Thank you for your perceptive answer.  Yes, I was wrong to say the
BEAN SHELL ASSERTION script was being skipped.

I have:

Thread Group (1/0/1)
+ HTTP Cache Manager (clear cache)
+ HTTP Cookie Manager (clear cookies)
+ Simple Controller
++ HTTP Request
+++HTTP Header Manager (host, accept, useragent, etc)
++Bean Shell Assertion
++ Assertion Results
+ View Results Tree
+ Mailer Visualizer

The BEAN SHELL ASSERTION now contains only:

   print("Start of script 27b");
   print(vars.get("JMeterThread.last_sample_ok"));
   print( ResponseCode);

With a valid tested server port:

  Start of script 27b
  true
  200

and we have success.

When changing the HTTP request to an invalid port (just to fake the test):

  Start of script 27b
  true
  Non HTTP response code: java.net.SocketTimeoutException

and the Mailer Visualizer sees an error (failure).  The sampler result is:

   Thread Name: *************
   Sample Start: 2012-04-08 03:40:54 BST
   Load time: 5005
   Latency: 0
   Size in bytes: 1577
   Sample Count: 1
   Error Count: 1
   Response code: Non HTTP response code: java.net.SocketTimeoutException
   Response message: Non HTTP response message: connect timed out

  Response headers:

   HTTPSampleResult fields:
   ContentType:
   DataEncoding: null

So, I suppose my simpler question is, how would I conditionally branch
on the HTTP Request sampler error, and only do other assertion tests
and email if a non null status code is returned?  I'm happy to do this
in the Bean Shell script, if it isn't possible with the standard
Jmeter components.

Adam


On 27 January 2011 12:02, sebb <se...@gmail.com> wrote:
> On 27 January 2011 11:44, Adam Ploverall <ad...@googlemail.com> wrote:
>> Hello
>>
>> I have been trying to build some conditional logic into my tests, and
>> have been trying the IF CONTROLLER, RESPONSE ASSERTION and BEAN SHELL
>> ASSERTIONs.  Sometimes, my HTTP SAMPLER gets a timeout response like:
>>
>>   java.net.SocketTimeoutException: connect timed out
>>
>>   or
>>
>>   java.net.SocketTimeoutException: Read timed out
>>
>> These might be due to lack of resources, or the tested site being
>> down.  But it seems the HTTP SAMPLER is setting these:
>>
>>   Error Count: 1
>>   Response code: Non HTTP response code: java.net.SocketTimeoutException
>>
>> and I can't work out how to suppress this, and say skip a subsequent
>> MAILER VISUALIZER.
>>
>> In a BEAN SHELL ASSERTION, I have tried:
>>
>>   if (ResponseCode.equals(null)==false && ResponseCode.equals("Non
>> HTTP response code: java.net.SocketTimeoutException")==false)  {
>>
>>   ...
>>
>>   }
>>
>> but the sampler seems to be skipped due to the HTTP SAMPLER error.  If
>
> Do you mean the assertion is skipped?
> Are you sure? Try adding a print("message") call to the start of BSH Assertion.
>
> Also print out the values of critical variables in the script.
>
> And check jmeter log file for script errors.
>
>> I use a RESPONSE ASSERTION, I can ignore the status code (checkbox),
>> but then have little control about what happens next.
>>
>> My aim is to do something like this:
>>
>> 1. Do an HTTP request
>> 1a) 5 min timer delay (Constant Timer)
>>
>> 2. If the response has a status code and content (else skip to 3.):
>> 2a) do some other response assertion tests on the headers and content
>> 2b) use the mailer visualiser to alert on any failure (0/0 setting)
>> 2c) Skip to 4.
>>
>> 3. If a java.net.SocketTimeoutException occurs
>> 3a) use the mailer visualiser to alert on two failures (1/0 setting)
>> 3b) reset the failure count to 0 if we haven't had another failure in X minutes
>> 3c) Continue to 4
>>
>> 4. Continue indefinite loop
>>
>> In other words, treat the 3s with less priority.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Handling of java.net.SocketTimeoutException errors

Posted by sebb <se...@gmail.com>.
On 27 January 2011 11:44, Adam Ploverall <ad...@googlemail.com> wrote:
> Hello
>
> I have been trying to build some conditional logic into my tests, and
> have been trying the IF CONTROLLER, RESPONSE ASSERTION and BEAN SHELL
> ASSERTIONs.  Sometimes, my HTTP SAMPLER gets a timeout response like:
>
>   java.net.SocketTimeoutException: connect timed out
>
>   or
>
>   java.net.SocketTimeoutException: Read timed out
>
> These might be due to lack of resources, or the tested site being
> down.  But it seems the HTTP SAMPLER is setting these:
>
>   Error Count: 1
>   Response code: Non HTTP response code: java.net.SocketTimeoutException
>
> and I can't work out how to suppress this, and say skip a subsequent
> MAILER VISUALIZER.
>
> In a BEAN SHELL ASSERTION, I have tried:
>
>   if (ResponseCode.equals(null)==false && ResponseCode.equals("Non
> HTTP response code: java.net.SocketTimeoutException")==false)  {
>
>   ...
>
>   }
>
> but the sampler seems to be skipped due to the HTTP SAMPLER error.  If

Do you mean the assertion is skipped?
Are you sure? Try adding a print("message") call to the start of BSH Assertion.

Also print out the values of critical variables in the script.

And check jmeter log file for script errors.

> I use a RESPONSE ASSERTION, I can ignore the status code (checkbox),
> but then have little control about what happens next.
>
> My aim is to do something like this:
>
> 1. Do an HTTP request
> 1a) 5 min timer delay (Constant Timer)
>
> 2. If the response has a status code and content (else skip to 3.):
> 2a) do some other response assertion tests on the headers and content
> 2b) use the mailer visualiser to alert on any failure (0/0 setting)
> 2c) Skip to 4.
>
> 3. If a java.net.SocketTimeoutException occurs
> 3a) use the mailer visualiser to alert on two failures (1/0 setting)
> 3b) reset the failure count to 0 if we haven't had another failure in X minutes
> 3c) Continue to 4
>
> 4. Continue indefinite loop
>
> In other words, treat the 3s with less priority.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org