Killing TCP connections


#1

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!


#2

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


#3

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.


#4

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