question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mitmdump 0.16 stops working and only passes "clientdisconnect" errors after a couple of hundred requests

See original GitHub issue

I am currently running mitmdump via a bash script (rerun.sh) with following parameters:

gtimeout 30s mitmdump -p 8513 -T --host --anticache -s py.py --ignore :443$’ ./rerun.sh

this is quick and (very) dirty solution because mitmdump stops working and only passes “clientdisconnect” errors after a couple of hundred requests.

this is my py.py:

# This function is run on each response from websites
def response(context, flow):
    with decoded(flow.response):
        if "application/javascript" == flow.response.headers.get('Content-Type', None) and ".js" == flow.request.url[-3:]:
            flow.response.content = flow.response.content + open('js.js', 'r').read()
from libmproxy.models import decoded

and I am getting a lot of these as well, that might or might not be related to the above issue, but perhaps might provide further clues as to what is up:

mitmproxy has crashed!
Please lodge a bug report at: https://github.com/mitmproxy/mitmproxy
192.168.2.7:50851: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/libmproxy/proxy/server.py", line 120, in handle
    root_layer()
  File "/usr/local/lib/python2.7/site-packages/libmproxy/proxy/modes/transparent_proxy.py", line 21, in __call__
    layer()
  File "/usr/local/lib/python2.7/site-packages/libmproxy/protocol/tls.py", line 272, in __call__
    layer()
  File "/usr/local/lib/python2.7/site-packages/libmproxy/protocol/http.py", line 130, in __call__
    layer()
  File "/usr/local/lib/python2.7/site-packages/libmproxy/protocol/http.py", line 338, in __call__
    self.get_response_from_server(flow)
  File "/usr/local/lib/python2.7/site-packages/libmproxy/protocol/http.py", line 469, in get_response_from_server
    if flow.response.stream:
AttributeError: 'NoneType' object has no attribute 'response'

while the present workaround is somewhat underperforming it is serviceable for now as i have to deployed this Saturday. But there must be less “hacky” way of solving this issue long term? This is my first time submitting an issue on GitHUb so please bear with me if I am not 100% up to protocol.

Mitmproxy Version: mitmproxy-0.16-osx.tar.gz Operating System: OSX

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
KristofferOrumcommented, Aug 3, 2016

I enden up using this Quick and Dirty solution, with a self referring bashscript rerun.sh:

gtimeout 30s mitmdump -p 8513 -T --host --anticache -s py.py --ignore :443$ . /rerun.sh

basically restarting it every 30 seconds - Not a perfect solution by any means, but serviceable in a pinch - Hope it helps…

0reactions
ShoutMarketcommented, Aug 7, 2016

Maybe you know how to get the clients ip from inside a script while running mitmdump?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mitmdump option error · Issue #3904 - GitHub
Type mitmdump abc. It doesn't show any flow after that just clientconnect and clientdisconnect on requests but no error about wrong argument.
Read more >
Options - mitmproxy docs
Name Type Description # allow_hosts mitmproxy mitmdump mitmweb sequence of str Opposite of ‑‑ignore‑hosts... # client_replay mitmproxy mitmdump mitmweb sequence of str Replay client requests...
Read more >
mitmproxy docs - Read the Docs
The mitmproxy CA cert is located in ~/.mitmproxy after it has been generated ... Mitmproxy passes the request on to the server over...
Read more >
mitmproxy Client and Server disconnects whenever a specific ...
I have an app on my Android phone I try to debug, but whenever I enable PcapDroid to send the TLS decrypted requests...
Read more >
Creating scripts for mitmproxy - Bad Gateway
If you already managed to set everything in order to run the program and catch requests, writting scripts should not be too complicated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found