2016-04-14 64 views
1

我提出地址解析請求使用要求網上搜尋API:的Python:要求谷歌地圖API - 握手問題

geo_url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + geo_address + '&key=' + GOOGLE_API_KEY 
geo_response = requests.get(url=geo_url, verify=False) 
geo = geo_response.json() 

在我CLOUD9 IDE它的工作原理semalessly。

在我的Ubuntu服務器與Apache和mod_wsgi的它工作的時候,但是經常失敗,並在阿帕奇error.log中的錯誤:

File "/var/virtualenv/primo/lib/python2.7/site-packages/django/utils/log.py", line 129, in emit 
    self.send_mail(subject, message, fail_silently=True, html_message=html_message) 
    File "/var/virtualenv/primo/lib/python2.7/site-packages/django/utils/log.py", line 132, in send_mail 
    mail.mail_admins(subject, message, *args, connection=self.connection(), **kwargs) 
    File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/__init__.py", line 98, in mail_admins 
    mail.send(fail_silently=fail_silently) 
    File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/message.py", line 303, in send 
    return self.get_connection(fail_silently).send_messages([self]) 
    File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages 
    new_conn_created = self.open() 
    File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 64, in open 
    self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile) 
    File "/usr/lib/python2.7/smtplib.py", line 649, in starttls 
    self.sock = ssl.wrap_socket(self.sock, keyfile, certfile) 
    File "/usr/lib/python2.7/ssl.py", line 487, in wrap_socket 
    ciphers=ciphers) 
    File "/usr/lib/python2.7/ssl.py", line 243, in __init__ 
    self.do_handshake() 
    File "/usr/lib/python2.7/ssl.py", line 405, in do_handshake 
    self._sslobj.do_handshake() 
    error: [Errno 0] Error 

我不明白什麼錯誤。請有人指出我正確的方向嗎?

+0

您使用的是什麼版本的請求? –

+0

請求== 2.5.3 – caliph

+1

現在最新版本是2.9.1,請嘗試升級並查看問題是否仍然存在 –

回答

1

經過長時間的研究,我發現它在密碼模塊中存在一個bug。

參見:https://github.com/pyca/cryptography/issues/2299

替代方法:將WSGIApplicationGroup%{GLOBAL}

在apache的虛擬主機配置例如

<Directory /var/www/path/to/wsgi> 
    <Files wsgi.py> 
     Require all granted 
    </Files> 
    WSGIApplicationGroup %{GLOBAL} 
</Directory> 
+0

謝謝。也解決了我的問題 - https://stackoverflow.com/questions/43643674/google-maps-bad-handshake – HenryM