toxiproxy icon indicating copy to clipboard operation
toxiproxy copied to clipboard

Introduce a toxic that closes a connection after given time period

Open mgkeen opened this issue 6 years ago • 5 comments

Whilst using toxiproxy to do some testing, i found the timeout toxic didn't quite suit my needs. If i understand it correctly, the timeout toxic doesn't allow data through at all. I needed a toxic that would allow a connection to carry data, and then cut off after some amount of time. I took inspiration from the limit_data toxic and introduced a limit_time toxic. There's probably a better name for it that i haven't thought of.

mgkeen avatar Nov 16 '17 17:11 mgkeen

Thanks for the PR @mgkeen. I'll try to look at it at some point next week.

jpittis avatar Nov 24 '17 18:11 jpittis

Thanks for the useful addition @mgkeen. I found one issue with this Toxic that we hit due to our use case. The current implementation doesn't work as expected (connection is not killed on timeout) if there is constant traffic on the connection (as was happening in my case with a WebSocket connection that is sending ping / pong every second).

The stub select case: case c := <-stub.Input: trips before any other and elapsed time is not recalculated.

sl1pm4t avatar May 23 '18 01:05 sl1pm4t

Any news on this? I've got to say this is the behaviour I was expecting "timeout" to have, and the cli help didn't make it clear it would prevent all data passthrough entirely.

Though maybe this could be merged into timeout and the traffic block behaviour would be either a separate toxic to combine with, or an attribute on the toxic? In fact it seems to me traffic blocking could be done by setting bandwidth to 0.

Though I guess if you're using the chaotic mode (toxicity != 1) you may want the toxics to always be enabled together… maybe the toxics should be more orthogonal but the toxicity should apply to groups of toxics rather than individual ones?

xmo-odoo avatar Aug 13 '18 08:08 xmo-odoo

As the previous comments suggest my implementation here probably doesn't work all that well. I might be able to have a go at doing this properly at some point soon, but I'm quite busy these days so there's a good chance that won't happen. If anybody else wants to pick it up then feel free!

mgkeen avatar Aug 14 '18 20:08 mgkeen

I think there is a way to have same with https://github.com/Shopify/toxiproxy/pull/333.

$ toxiproxy-cli toxic add --type reset_peer --toxicName "reset_peer" \                            
                       --attribute "timeout=2000" \
                       --toxicity 1.0 http

miry avatar Oct 22 '21 14:10 miry