Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GAE: ChunkedEncodingError: ('Connection broken: IncompleteRead(207 bytes read)', IncompleteRead(207 bytes read)) #18

Open
wooyek opened this issue Dec 25, 2015 · 4 comments

Comments

@wooyek
Copy link
Owner

wooyek commented Dec 25, 2015

There seem to be a problem with updated requests library on Google App Engine.

Exception on /_social/callback/Github [GET]
Traceback (most recent call last):
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask_social_blueprint/core.py", line 44, in callback
    return provider.authorized_handler(self.login)(provider=provider)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask_oauth.py", line 433, in decorated
    return f(*((data,) + args), **kwargs)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask_social_blueprint/core.py", line 54, in login
    profile = provider.get_profile(raw_data)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/flask_social_blueprint/providers.py", line 179, in get_profile
    r = requests.get('https://api.github.com/user?access_token={}'.format(access_token))
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/sessions.py", line 608, in send
    r.content
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/models.py", line 737, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/models.py", line 663, in generate
    raise ChunkedEncodingError(e)
ChunkedEncodingError: ('Connection broken: IncompleteRead(207 bytes read)', IncompleteRead(207 bytes read))

I may or may not be connected to a InsecurePlatformWarning:

/base/data/home/apps/s~flask-social-blueprint/3.389521229691342073/lib/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

Solution:

https://urllib3.readthedocs.org/en/latest/security.html#pyopenssl

results:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521383891920475/main.py", line 74, in <module>
    import urllib3.contrib.pyopenssl
  File "/base/data/home/apps/s~flask-social-blueprint/3.389521383891920475/lib/urllib3/contrib/pyopenssl.py", line 49, in <module>
    from ndg.httpsclient.ssl_peer_verification import SUBJ_ALT_NAME_SUPPORT
ImportError: No module named ndg.httpsclient.ssl_peer_verification

Solution http://stackoverflow.com/a/29507367/260480

e33d26a

Have no effect.

@gjgd
Copy link

gjgd commented Apr 19, 2016

I'm having the same problem:
ChunkedEncodingError on GAE.
No InsecurePlatformWarning though. I'm only trying to access the web service with http, not https

@cnicodeme
Copy link

I'm having the same issue on GAE, try this solution : kennethreitz/requests@master...agfor:master

From : urllib3/urllib3#618

@anotherstarburst
Copy link

@cnicodeme You sir are a legend! Solved this issue for me - thank you!

@ashmishra
Copy link

ashmishra commented Jan 11, 2017

In situations where "requests" is a dependency by other packages , you may not be easily able to provide your own library
This code patches the existing classes, and you can call it from your init.py

gae_request_incompleteReadFix.txt

Tested with GAE
Works!

ayip001 added a commit to ayip001/ayip.io that referenced this issue Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants