I am running a basic web server with a Flask application over HTTPS, call it https://myappserver:5000 Everything works fine until I need to make a call to an external API, alpha vantage. As soon as I request the data with something like data = ti.get_sma(symbol=symbol, interval='daily', time_period=60) I get an error that looks like this:
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1813, in
full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1799, in
dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "myflask.py", line 18, in add_numbers
data = get_data(a, hashvalue)
File "/opt/app/Get_Data.py", line 15, in get_data
sma60, _ = ti.get_sma(symbol=symbol, interval='daily', time_period=60)
File "/usr/local/lib/python2.7/dist-packages/alpha_vantage/alphavantage.py",
line 175, in _format_wrapper
self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/alpha_vantage/alphavantage.py",
line 160, in _call_wrapper
return self._handle_api_call(url), data_key, meta_data_key
File "/usr/local/lib/python2.7/dist-packages/alpha_vantage/alphavantage.py",
line 76, in _retry_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/alpha_vantage/alphavantage.py",
line 268, in _handle_api_call
response = requests.get(url, proxies=self.proxy)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 58, in
request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 508,
in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 640,
in send
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 218,
in resolve_redirects
**adapter_kwargs
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 618,
in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 506,
in send
raise SSLError(e, request=request)
SSLError: HTTPSConnectionPool(host='www.alphavantage.co', port=443): Max
retries exceeded with url: /query?function
=SMA&symbol=DATA&interval=daily&time_period=60&series_type=close&apikey=<API key> (Caused by SSLError(SSLErr
or("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))
209.249.175.115 - - [27/Sep/2018 17:11:56] "GET /_add_numbers?a=DATA HTTP/1.1" 500 -
Can someone please shed some light on what I would be doing wrong in this situation? If my web server is running on HTTP then this whole process works just fine. Thanks.