Killing TCP connections

Hi guys. I am trying to simulate occasional network glitches during websocket packet transfer. I posted some time ago about killing individual websocket messages and it eventually worked, however I did not realise the client will believe the packet reached the target with such an approach.

Is there any way to abruptly close TCP connections? (I see there is already a tcp_message(flow) event)

Thanks and happy winter holidays!

Does calling flow.kill() in the handler work for you?

There is an open issue about proxy crashing on flow.kill() - https://github.com/mitmproxy/mitmproxy/issues/2724

Can’t verify until it is fixed.

The issue is fixed and I verified that flow.kill() shoots the TCP messages down as intended. Thanks guys!

1 Like