Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

"499 Client Error: Client Disconnected for url: https://upload.pypi.org/legacy/" #675

Closed
s-m-e opened this issue Jul 26, 2017 · 12 comments
Closed

Comments

@s-m-e
Copy link

s-m-e commented Jul 26, 2017

I filed a detailed bug against twine but eventually learned that it also occurs when using setuptools (setup.py ... upload). So it might be an issue in pypi-legacy instead (?).

In a nutshell: I want to upload a (new) package to pypi after having successfully tested it (many times) with pypitest with identical configuration parameters. Uploading of files to pypi fails with HTTP error 499 (with both, twine and setuptools).

My .pypirc file looks like this:

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
username=username
password=password

[pypitest]
repository=https://test.pypi.org/legacy/
username=username
password=password

I am using Python 3.6.1 on Linux x86_64 with twine (1.9.1), requests (2.18.2), requests-toolbelt (0.8.0), urllib3 (1.22) and setuptools (36.2.2).

Even without the repository=... parameter in .pypirc, twine defaults to https://upload.pypi.org/legacy/ when trying to upload to pypi. Fun part: The behavior does not change at all if I provide false login credentials like a wrong password. Logging into pypi via the website works for me, however.

As far as I can tell, HTTP 499 is an error code specific to nginx indicating that the client "just" disconnected. Is this a timeout issue due to server load on pypi or did I misconfigure .pypirc in some sort of way (masquerading a log-in issue for instance) or is this a bug?

I have also tried to follow outdated instructions and attempted to register my files / project first - no change.

EDIT (1): I hacked twine a bit to get more detailed debugging output by patching the _upload routine in twine/repository.py. Now it shows me the full server response, i.e. resp.text / resp.content. Turns out to be interesting. Error 499 is accompanied by an HTML page:

('<!DOCTYPE html>\n'                                                                                                                                  
 '\t<html>\n'
 '\t  <head>\n'
 '\t\t<meta name="viewport" content="width=device-width, initial-scale=1">\n'
 '\t\t<meta charset="utf-8">\n'
 '\t\t<title>Application Error</title>\n'
 '\t\t<style media="screen">\n'
 '\t\t  html,body,iframe {\n'
 '\t\t\tmargin: 0;\n'
 '\t\t\tpadding: 0;\n'
 '\t\t  }\n'
 '\t\t  html,body {\n'
 '\t\t\theight: 100%;\n'
 '\t\t\toverflow: hidden;\n'
 '\t\t  }\n'
 '\t\t  iframe {\n'
 '\t\t\twidth: 100%;\n'
 '\t\t\theight: 100%;\n'
 '\t\t\tborder: 0;\n'
 '\t\t  }\n'
 '\t\t</style>\n'
 '\t  </head>\n'
 '\t  <body>\n'
 '\t\t<iframe '
 'src="//www.herokucdn.com/error-pages/application-error.html"></iframe>\n'
 '\t  </body>\n'
 '\t</html>')

The page in the iframe says "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. " ... My pypi username is "smernst", the package I am trying to upload is named "zugbruecke".

@s-m-e
Copy link
Author

s-m-e commented Jul 28, 2017

After a lot of tests I learned the following:

  • Baseline: My configuration, which works just fine with pypitest, no matter what.
  • On two of my machines, both running openSUSE Leap 42.2, latest patch level, running various versions of CPython 3.4, 3.5 and 3.6, it always fails with HTTP 499. It's not the version of (C)Python. It's not an outdated Python module (I checked them all).
  • In a new & clean VM running Ubuntu 17.04 with its default CPython 3.5, it fails with HTTP 499.
  • Getting a new IP from my ISP does not change anything. (In fact having had more than 5 different IPs over 3 days did not change anything.)
  • Re-routing my traffic through AWS (SOCKS5 proxy of my own) works (wtf)

So, as a (hopefully temporary) workaround I can only recommend the following:

# first shell
ssh -D 8080 some_server_instance_in_aws
# second shell
pip install -vU requests[socks]
export http_proxy=socks5://127.0.0.1:8080 https_proxy=socks5://127.0.0.1:8080
twine upload $filename $filename.asc

The first command connects to my AWS instance via SSH and uses it as a SOCKS proxy on port 8080. You can run this in the background, but I prefer to run it in a separate shell so I see what is going on.
The second command (in a new shell) adds SOCKS support to requests. The third one changes the http_proxy environment variable telling programs about the proxy (twine will honor it) and the fourth one just uploads my package as expected. I only need to do this for pypi, not for pypitest.

@boazmohar
Copy link

Have the same problem. Could not verify that re-routing works ( I don't have a AWS instance).
Would be happy for any other recommendations.
Recreated in Windows, Mac and Unix.
Again a wrong password in pypirc has no effect.

@s-m-e
Copy link
Author

s-m-e commented Aug 1, 2017

@boazmohar I had a few chats on freenode#pypa (IRC) with pypi people - the authentication happens after the upload. Since the upload fails, wrong login credentials have no effect. From where / what kind of network / ISP are you trying to upload? Seems like this issue is not an isolated case if you're trying to do this from the other side of the Atlantic. My ISP is Germany's T-Online.

(Maybe you have access to a university computer or proxy you could use for re-routing traffic through it?)

@boazmohar
Copy link

@s-m-e I can verify that using my phone as a wifi hotspot I can upload to pypi. My institute is HHMI Janelia research campus. I filed a help-desk ticket for them to unblock the traffic. I will report back if that was indeed the cause.

@k0rmarun
Copy link

k0rmarun commented Aug 6, 2017

Same over here.
This issue appears on :

  • ubuntu 16.04
  • mageia 6
  • win 7

and in the networks of:

  • UnityMedia (German ISP)
  • Heidelberg University
  • Hetzner

Could not verify Amazon trick due to missing instance

@Faeriol
Copy link

Faeriol commented Aug 23, 2017

For those of you with this issue... Can you check what version of requests you are using? This didn't work for me until I downgraded from 2.18.4 to 2.14.2.

Edit: If we get a few confirmations, I might just dig into the issue for fun
Edit 2: Now that I've got this working on any box, I can't seem to reproduce on any other... Strange

@coldfix
Copy link

coldfix commented Oct 24, 2017

@s-m-e I have the same issue, from unitymedia network south germany (Heidelberg). I can verify that proxying via my vserver as by your description solves the issue!

Possibly any proxy into a different network may solve the issue.

@coldfix
Copy link

coldfix commented Oct 24, 2017

@Faeriol downgrading requests did not work for me.

@ewdurbin
Copy link
Member

uploads are no longer accepted by the pypi-legacy codebase.

further discussion of this issue should be filed with https://github.com/pypa/warehouse/issues

@s-m-e
Copy link
Author

s-m-e commented Oct 25, 2017

@ewdurbin While I appreciate an answer from someone working on PyPI, I'd like to suggest to update the documentation (in a number of places) of how to upload a Python package, where to file bugs (for certain "sub systems" of PyPI) and what the current state of affairs is with regards to "pypi-legacy" and "warehouse". I gathered my info with respect to the current upload process and this bug from all sorts of places, including podcasts (interviews) and irc chats. It is by no means obvious to the outside world, which piece of code is actually responsible for accepting uploads to PyPI and where to file bugs. There is a new website, and an old one, there is a new "pre-production" backend, and there is an old one, there are different upload URLs (not) doing different things ... After all, pypi.org still has a warning at its top ("This is a pre-production deployment of Warehouse"). I suggest to replace it with a line telling people that you need help with updating your documentation and a link to where interested folks should go first ;)

@ewdurbin
Copy link
Member

@s-m-e thanks for the wall of text.

@ewdurbin
Copy link
Member

@s-m-e Trying to break down your larger concerns:

Overall, this is no longer to do with the 499 issue and if you'd like to continue to discuss checkout https://github.com/pypa/packaging-problems

@pypi pypi locked and limited conversation to collaborators Oct 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants