Simulate slow netowrk connection

Hi,

I am using mitmproxy to test and monitor API calls for our iOS app. Now my next use-case is to test how our app reacts in slow network conditions. I was wondering how I can use Mitmproxy to simulate a slow network connection. First thought which came to my mind is to have random time.sleep() in my def response() methods, but probably this is a very naive way to achieve this ? Any suggestions ?

Regards,
Kapil.

Unfortunately no response to my query yet. I hope it was not an ignorable stupid question which I asked :slight_smile:

Regards,
Kapil.

Hi @qakapil,

You can use time.sleep() in the response hook (don’t forget to set the concurrent decorator in that case), but to be honest we don’t really have good means in mitmproxy to simulate connection troubles at the moment. I’d suggest checking for a dedicated app that does packet dropping, slowdown, etc.

Cheers,
Max