SSL Error: bad handshake when use requests lib

741 views
Skip to first unread message

killzane

unread,
Dec 20, 2017, 2:58:32 AM12/20/17
to web2py-users
Hi

I want to use Requests lib in web2py to run facebook's Graph API.
So I need to use requests.get or requests.post.

The problem is, when I run requests.get in python, it's work.
but when I run in web2py, it gave me an error

<class 'requests.exceptions.SSLError'> HTTPSConnectionPool(host='graph.facebook.com', port=443): Max retries exceeded with url: /v2.6/me?fields=id%2Cname&access_token=<ACCESS_TOKEN> (Caused by SSLError(SSLError('bad handshake: SysCallError(0, None)',),))

web2py: 2.16.1-stable
Apache: 2.4.18 (Ubuntu)
Python: 2.7.12
Requests: 2.18.4

DaneW

unread,
Dec 21, 2017, 5:00:01 AM12/21/17
to web2py-users
I recently have the same problem with certain websites - it seems to be an OpenSSL issue with their webserver config or their certificates.

Could you tell us what version of OpenSSL is used both circumstances? terminal> openssl version and Python> print ssl.OPENSSL_VERSION 

killzane

unread,
Dec 21, 2017, 5:11:10 AM12/21/17
to web2py-users
1. unubtu terminal
OpenSSL 1.0.2g  1 Mar 2016

2. python
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.2g  1 Mar 2016


DaneW於 2017年12月21日星期四 UTC+8下午6時00分01秒寫道:

DaneW

unread,
Dec 21, 2017, 7:02:26 PM12/21/17
to web2py-users
I see that they are the same version and it is reasonably up to date. Presumably that is also the version used when you run a script within Web2py? If so then I'm afraid I don't have any further suggestions - sorry. I don't have a Facebook access token so I can't try it out - perhaps there is someone else who uses the Facebook Graph API?  

killzane

unread,
Dec 22, 2017, 3:26:50 AM12/22/17
to web...@googlegroups.com
Hi I try to use web2py console.
and requests work well...

but it can't work in my controller

btw, I try to make a https request to other address, and it work well...
I think only fb request has this problem

DaneW於 2017年12月22日星期五 UTC+8上午8時02分26秒寫道:
Reply all
Reply to author
Forward
0 new messages