pythonic-emacs / anaconda-mode

Code navigation, documentation lookup and completion for Python.
GNU General Public License v3.0
710 stars 87 forks source link

Cannot read anaconda-mode server response behind proxy #341

Closed gpanders closed 5 years ago

gpanders commented 5 years ago

So I know this issue has been brought up before. But my problem doesn't seem to match what others are experiencing.

I work behind a corporate proxy. When I'm not connected to my work network everything works fine, but as soon as I connect to my VPN things go bunk.

Here is my init.el:

(setq url-proxy-services '(("http" . "wwwproxy.mycompany.com:80")
                           ("https" . "wwwproxy.mycompany.com:80")
                           ("ftp" . "wwwproxy.mycompany.com:80")
                           ("no_proxy" . "127.0.0.1,localhost,.mycompany.com")))

;; Trying this out
(setenv "no_proxy" "127.0.0.1,localhost")

(use-package anaconda-mode
  :ensure t
  :hook ((python-mode . anaconda-mode)
         (python-mode . anaconda-eldoc-mode))
  :init
  (setq anaconda-mode-localhost-address "localhost")
  :config
  (use-package company-anaconda
    :ensure t
    :after company
    :config
    (add-to-list 'company-backends '(company-anaconda :with company-capf))))

I have tried with and without setting anaconda-mode-localhost-address.

Below is the *anaconda-response* log. It is reporting that it could not connect to 127.0.0.1:62839; however, lsof -nPi4:62839 shows that the port is LISTENING.

I noticed the presence of a Squid server. I don't have one installed as far as I know. Is that part of anaconda-mode? If not, then I suspect it is part of my company's proxy toolchain.

*anaconda-response*:

# status: (:error (error http 503))
# point: 341
HTTP/1.0 503 Service Unavailable
Server: squid/3.1.23
Mime-Version: 1.0
Date: Tue, 20 Nov 2018 13:57:58 GMT
Content-Type: text/html
Content-Length: 3434
X-Squid-Error: ERR_CONNECT_FAIL 111
X-Cache: MISS from sahp6005.mycompany.com
X-Cache-Lookup: MISS from sahp6005.mycompany.com:80
Via: 1.0 sahp6005.mycompany.com (squid/3.1.23)
Connection: close

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head> <meta http-equiv="Content-Type" CONTENT="text/html; charset=utf-8"> <title>ERROR: The requested URL could not be retrieved</title> <style type="text/css"><!--   /*
 Stylesheet for Squid Error pages
 Adapted from design by Free CSS Templates
 http://www.freecsstemplates.org
 Released for free under a Creative Commons Attribution 2.5 License
*/

/* Page basics */
* {
    font-family: verdana, sans-serif;
}

html body {
    margin: 0;
    padding: 0;
    background: #efefef;
    font-size: 12px;
    color: #1e1e1e;
}

/* Page displayed title area */
#titles {
    margin-left: 15px;
    padding: 10px;
    padding-left: 100px;
    background: url('http://www.squid-cache.org/Artwork/SN.png') no-repeat left;
}

/* initial title */
#titles h1 {
    color: #000000;
}
#titles h2 {
    color: #000000;
}

/* special event: FTP success page titles */
#titles ftpsuccess {
    background-color:#00ff00;
    width:100%;
}

/* Page displayed body content area */
#content {
    padding: 10px;
    background: #ffffff;
}

/* General text */
p {
}

/* error brief description */
#error p {
}

/* some data which may have caused the problem */
#data {
}

/* the error message received from the system or other software */
#sysmsg {
}

pre {
    font-family:sans-serif;
}

/* special event: FTP / Gopher directory listing */
#dirmsg {
    font-family: courier;
    color: black;
    font-size: 10pt;
}
#dirlisting {
    margin-left: 2%;
    margin-right: 2%;
}
#dirlisting tr.entry td.icon,td.filename,td.size,td.date {
    border-bottom: groove;
}
#dirlisting td.size {
    width: 50px;
    text-align: right;
    padding-right: 5px;
}

/* horizontal lines */
hr {
    margin: 0;
}

/* page displayed footer area */
#footer {
    font-size: 9px;
    padding-left: 10px;
}
  body :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; } :lang(he) { direction: rtl; float: right; }--></style> </head>
<body>
  <div id="titles">
    <h1>ERROR</h1>
    <h2>The requested URL could not be retrieved</h2>
  </div>
  <hr>
  <div id="content">
    <p>The following error was encountered while trying to retrieve the URL: <a href="http://127.0.0.1:62839/">http://127.0.0.1:62839/</a></p>
    <blockquote id="error">
      <p><b>Connection to 127.0.0.1 failed.</b></p>
    </blockquote>
    <p id="sysmsg">The system returned: <i>(111) Connection refused</i></p>
    <p>The remote host or network may be down. Please try the request again.</p>
    <p>Your cache administrator is <a href="mailto:redacted?subject=CacheErrorInfo%20-%20ERR_CONNECT_FAIL&amp;body=CacheHost%3A%20sahp6005.mycompany.com%0D%0AErrPage%3A%20ERR_CONNECT_FAIL%0D%0AErr%3A%20(111)%20Connection%20refused%0D%0ATimeStamp%3A%20Tue,%2020%20Nov%202018%2013%3A57%3A58%20GMT%0D%0A%0D%0AClientIP%3A%20134.253.112.208%0D%0AServerIP%3A%20127.0.0.1%0D%0A%0D%0AHTTP%20Request%3A%0D%0APOST%20%2F%20HTTP%2F1.1%0AMime-Version%3A%201.0%0D%0AConnection%3A%20close%0D%0AExtension%3A%20Security%2FDigest%20Security%2FSSL%0D%0AHost%3A%20127.0.0.1%3A62839%0D%0AAccept-Encoding%3A%20gzip%0D%0AAccept%3A%20*%2F*%0D%0AUser-Agent%3A%20URL%2FEmacs%20Emacs%2F26.1%20(OpenStep%3B%20x86_64-apple-darwin14.5.0)%0D%0AContent-Length%3A%2010659%0D%0A%0D%0A%0D%0A"></a></p>
    <br>
  </div>
  <hr>
  <div id="footer"> <p>Generated Tue, 20 Nov 2018 13:57:58 GMT by sahp6005.mycompany.com (squid/3.1.23)</p> <!-- ERR_CONNECT_FAIL --> </div> </body></html> 
valignatev commented 5 years ago

Looks like your company's Squid hijacks the port which anaconda-mode has been trying to use. I think the only solution for this is either do something so the proxy doesn't do this anymore, or to improve anaconda-mode so it accepts valid ports which it should use.

CeleritasCelery commented 5 years ago

You can change anaconda-mode-localhost-address to a different port that is free behind your proxy.

gpanders commented 5 years ago

I think this is now solved by making sure localhost is not intercepted by my proxy (by adding it to the no_proxy environment variable and the Network Preferences in macOS).