Recommended way to catch errors on Read Sampler
Hi
I am using your package with Stomp - which has been running successfully for a while. However now connecting to a new target setup and we are having problems with dropped/lost WebSocket connections.
The general scheme is: - Stomp Connect message sent using a WebSocket Single Write Sampler (with "setup a new connection). - WebSocket Read Sampler to get response message - With a Response Assertion checking for "CONNECTED"
That bit works ok - no Assertion error thrown
Then - Stomp Subscribe message using WebSocket Single Write Sampler - Subscribe does not respond with a message
Then in a loop
- Get a published message using WebSocket Single Read Sampler
- with "use existing connection"
- response timeout 1000ms
This last is throwing an error - potentially as the connection is lost/closed.
Is there a recommended way to catch the error on the Read Sampler? Is this possible with BeanShell (using prev?) ?
That would at least allow me to exit the loop cleanly and potentiall re-connect. Without this the loop is spinning through quickly without the clean timeout holding it up. I have attempted to slow this down by using shorter timeout and a "Constant Timer" - but think it would be cleaner to catch the error and exit the loop.
Obviously the cause of the lost connection is outside the scope of this queston (that I need to work out my side).
Comments (2)
-
-
repo owner Hi David,
Is this possible with BeanShell (using prev?) ?
I don’t know; i never tried. But your approach sounds good to me.
W.r.t. the AWS LoadBalancer thing: that does not surprise me, i’ve seen similar behaviour with other Cloud service providers. It’s quite common they close a connection when it has been idle for some time (30 seconds, 1 minute).
Regards
Peter - Log in to comment
Looking at the code I believe I can get the SamplerResult.getResponseCode() via prev - as this gets set in the WebSocketReadSampler. I will give that a try.
I have also fixed the underlying WebSocket failures - this test scenario was into an AWS setup with a LoadBalancer - I have extended the script to use the WebSocket ping/pong Sampler every 20 seconds. I believe the Load Balancer must have been closing (what it saw as) “idle” sessions.