tamper icon indicating copy to clipboard operation
tamper copied to clipboard

Could not connect to proxy

Open BrandesEric opened this issue 9 years ago • 35 comments

I've seen the steps @saalmaan came up with to get things working on OSX. I have tried that, but am still not able to connect to the mitmproxy.

I have confirmed that mitmproxy itself is working fine (it can capture traffic without issue). Further, I installed it via pip, not from binaries, so hopefully that is not the issue.

I'm not sure what else I can try?

BrandesEric avatar Dec 19 '14 21:12 BrandesEric

Hi @BrandesEric are you trying to install this on MacOSX? After installing the tamper, did you see the success message? saying something like

Successfully installed tamper mitmproxy pyOpenSSL Pillow netlib lxml Werkzeug Jinja2 itsdangerous certifi backports.ssl-match-hostname cryptography markupsafe cffi pycparser

also did you restart the proxy in tamper's chrome extension? and enabled the plugin?

if all of the above is working and you tried all that, then can you post a screen shot of tamper chrome plugin?

Thanks

saalmaan avatar Dec 19 '14 23:12 saalmaan

Yep, I did see the success message. Here are some screenshots :)
screen shot 2014-12-21 at 4 53 00 pm screen shot 2014-12-21 at 4 53 49 pm

This behaves the same whether I have mitmproxy running or not.

BrandesEric avatar Dec 21 '14 22:12 BrandesEric

Thank you for the screenshots, did you try to restart proxy in the chrome plugin, from the wheel icon in left hand side of tamper plugin?

saalmaan avatar Dec 21 '14 23:12 saalmaan

Yep yep, I have tried that with both mitmproxy running in a terminal window and with it NOT running in a terminal window. Honestly, whenever I click the restart button nothing seems to happen. It's like it's not really doing anything?

On Sun, Dec 21, 2014 at 5:31 PM, saalmaan [email protected] wrote:

Thank you for the screenshots, did you try to restart proxy in the chrome plugin, from the wheel icon in left hand side of tamper plugin?

— Reply to this email directly or view it on GitHub https://github.com/dutzi/tamper/issues/23#issuecomment-67789891.

BrandesEric avatar Dec 22 '14 05:12 BrandesEric

Got the same issue, how does this tries to start the proxy?

gaborbernat avatar Feb 28 '15 13:02 gaborbernat

By runing a python script through chrome's native application API. Did you install both the extension and the tamper Python package through pip? On Sat, Feb 28, 2015 at 15:31 Gábor Bernát [email protected] wrote:

Got the same issue, how does this tries to start the proxy?

Reply to this email directly or view it on GitHub https://github.com/dutzi/tamper/issues/23#issuecomment-76526175.

dutzi avatar Feb 28 '15 13:02 dutzi

Yes of course, I should not I'm on Linux(Arch). Not sure into which python should I install, how does you call it from Chrome?

gaborbernat avatar Feb 28 '15 14:02 gaborbernat

please see the troubleshooting guide below, this should help some installation/configuration questions. https://github.com/dutzi/tamper/wiki/Troubleshooting

saalmaan avatar Feb 28 '15 15:02 saalmaan

Any other ideas? So if I open up a console and run mitmproxy it starts. If I configure a proxy plugin to route traffic via it, it works. However from Chrome I can only see a Could not connect to proxy message, even though I change the port and such :)

gaborbernat avatar Feb 28 '15 18:02 gaborbernat

I think this has something to do that altough tamper installs fine, it does throw a warning:

copying build/scripts-2.7/tamper.py -> /usr/local/bin

changing mode of /usr/local/bin/tamper.py to 755

writing list of installed files to '/tmp/pip-klsxZt-record/install-record.txt'

error: [Errno 2] No such file or directory: '/home/bernat/Library/Application Support/Google/Chrome/NativeMessagingHosts/'

This folder is OS specific, as this does seem to be MacOS path, do your resolve this path OS angosticly?

gaborbernat avatar Feb 28 '15 18:02 gaborbernat

@gaborbernat seems like troubleshotting guide didn't help, you need @dutzi he the man for advance debugging :)

saalmaan avatar Feb 28 '15 19:02 saalmaan

Okay, @dutzi let me know if I can assist with anything :)

gaborbernat avatar Mar 01 '15 15:03 gaborbernat

Hi @gaborbernat @BrandesEric can you please both run chrome in full verbose debug mode, here is the command for mac osx (close chrome before running this command) /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-logging --v=1

and let me know what error you see in the console.

Many thanks

saalmaan avatar Apr 27 '15 12:04 saalmaan

Abandoned this, instead using nginx + mitmproxy + a chrome proxy extension.

gaborbernat avatar Apr 27 '15 12:04 gaborbernat

make sure you have "com.dutzi.tamper.json" at folder below /Users/USER-NAME/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json

saalmaan avatar Apr 27 '15 15:04 saalmaan

I'm having the same problem... On mac (latest everything), both installed via pip, mitmproxy runs, restarted proxy via chrome/tamper plugin panel. No NativeMessagingHosts folder so I added one and also added "com.dutzi.tamper.json", makes no difference.

Any solution to this yet?

@gaborbernat any Tuts on how to set that up?

Thanks

ghost avatar May 28 '15 13:05 ghost

Ok, I uninstalled tamper via pip and then installed again (in the same way as before), now it works ?!? Maybe this will work for others.

ghost avatar May 28 '15 13:05 ghost

Uninstalling and reinstalling tamper via pip worked for me as well.

juneeighteen avatar Jun 05 '15 14:06 juneeighteen

Sorry, Mac OS X Thread. Moved https://github.com/dutzi/tamper/issues/28

a904guy avatar Jun 14 '15 16:06 a904guy

made an observation, installing tamper with pip while chrome browser is open doesn't work, but if chrome is closed it always works, so for future reference, close any instances of chrome and then install tamper. this should do the trick

saalmaan avatar Aug 09 '15 00:08 saalmaan

@BrandesEric have you managed to install tamper? can we close this issue now?

saalmaan avatar Aug 09 '15 00:08 saalmaan

I'm having the same issue. Reinstalling tamper via pip while Chrome was closed did not work. I ran Chrome in debug mode and saw a bunch of these errors:

[48531:36099:1009/113054:ERROR:native_process_launcher.cc(140)] Failed to load manifest for native messaging host com.dutzi.tamper: Invalid value for path.

I've verified that com.dutzi.tamper.json exists in the correct location.

chrisjaure avatar Oct 09 '15 16:10 chrisjaure

@chrisjaure, this issue has been driving me insane and I have a quick fix for you and anyone else running into this issue. First of all, we may be running into this issue because of #31. When I looked at my com.dutzi.tamper.json file, I saw:

{
    "allowed_origins": [
        "chrome-extension://mabhojhgigkmnkppkncbkblecnnanfmd/",
        "chrome-extension://ecgndobpbcogellijibmcnjflahddidl/"
    ],
    "description": "Extends the Developer Tools, lets you locally edit files served from the web using Mitmproxy.",
    "name": "com.dutzi.tamper",
    "path": null,
    "type": "stdio"
}

if the path is null, Chrome can't find the executable. This JSON file gets generated and written into ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json in setup.py when you pip install tamper.

Chrome wants a full path in that field, so I grabbed it via which tamper.py, which returned /usr/local/bin/tamper.py and replaced null with "/usr/local/bin/tamper.py".

I restarted Chrome (and also probably uninstalled and reinstalled the tamper Chrome extension) and it worked!

It may link to #31 because if find_executable is failing for non win32 builds, then the path can never be populated which may the reason I had a null value for that.

ryanbaer avatar Nov 01 '15 02:11 ryanbaer

So I've done some more digging and want to highlight what I've discovered. First, my system:

  • OS X Yosemite 10.10.5
  • Python 2.7.10
  • pip 7.1.2 from /Library/Python/2.7/site-packages (python 2.7)

Whenever I first blindly tried installing this package and ran into "Cannot connect to proxy", I noticed at one point that I did have a com.dutzi.tamper.json file and the path was null. However, after several later attempts, I actually can't reproduce getting that file placed in there with a null path to figure out what's going on behind #31.

It's notable that all of this time I've been using sudo pip install to get around that annoying permissions error instead of chmoding the site-packages directory. After uninstalling and reinstalling a few times, I noticed that setup would run just fine, but the com.dutzi.tamper.json file was never getting added to Chrome in ~/Library/Application Support.

Some debugging of the post install script revealed that this line is the problem for my particular method of sudo pip install. The file still gets created, but in the wrong place. Since I was executing as root, it thought my home directory was /var/root, and so expanduser actually resolves to: /var/root/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json instead of the expected ~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json.

However I did find that running sudo pip install --no-cache-dir tamper actually resolves this issue. My theory on why this works is that, when pip caches the wheel of the package, it does not include the post install script. Running sudo pip install -v tamper showed me the path to the cached wheel being used. Installing directly from the wheel, even with --no-cache-dir, like so: sudo pip install tamper-0.24.5-py2-none-any.whl --no-cache-dir does not result in com.dutzi.tamper.json getting created in either places (/var/root/Library/... or ~/Library/...). Decompressing the wheel and viewing the contents also seems to support this theory as well - no mention of any post-install script, just the assets and the tamper.py script.

So when you sudo pip install tamper --no-cache-dir, I'm guessing it is fetching it in some other form that causes the post install script to actually run, perhaps as an egg.

A few solutions to fix the missing com.dutzi.tamper.json file:

  • Keep using sudo pip install and simply run with the --no-cache-dir flag like so: sudo pip install --no-cache-dir tamper.
  • Change permissions on your system Python site-packages dir so you don't need to be root to install.
  • Install in a virtualenv (post install hook will tell Chrome the correct location of your binary within the virtualenv).
  • Manually create ~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json and paste in the contents from here, then add a field, "path", setting it to the result of which tamper.py.

ryanbaer avatar Nov 02 '15 00:11 ryanbaer

I ran into this issue, with the missing path. A good way to check if this is true for you is to test start your editor for the settings menu. If nothing happens, then its not talking to the tamper.py.

sirwolfgang avatar Mar 10 '16 19:03 sirwolfgang

@sirwolfgang what editor and settings menu are you referring to?

jcrben avatar Jun 01 '16 23:06 jcrben

@jcrben he may just be referring Developer Tools to bring up the Console

Settings > More Tools > Developer Tools Shortcut: Alt + Cmd + i

Are you having an issue getting it running? You may want to look at ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json and see if path is null or not.

ryanbaer avatar Jun 02 '16 18:06 ryanbaer

This is broken for me too. python 2.7 and 3 are freshly reinstalled from homebrew. pip, setuptools, and tamper & mitmproxy all installed fine - all are shown in pip list (though I note that it installs an old version of mitmproxy), the path to tamper.py is in the plist file and points at the correct file. I uninstalled and reinstalled with --no-cache-dir but that didn't help. Everything is installed as me, not root, permissions are OK. I've reinstalled tamper extension, restarted chrome, but it still says "Could not connect to proxy". Notably I can't launch editors from the tamper panel either, and trying to start mitmproxy from a shell fails to find it, so I suspect path issues, but I've not found anywhere to tell me where python installs utilities.

Synchro avatar Aug 02 '16 18:08 Synchro

@Synchro hop on the repo's Gitter channel and I'll help you debug it: https://gitter.im/dutzi/tamper

ryanbaer avatar Aug 02 '16 18:08 ryanbaer

@Synchro did you try https://github.com/dutzi/tamper/wiki/Troubleshooting guide its been updated, that might help

saalmaan avatar Aug 02 '16 18:08 saalmaan