raven-python
raven-python copied to clipboard
raven test command failed with error
Software stack info is as flows:
- Sentry version: 8.19.0
- Python 3.5.2
- raven 6.8
I have created a new project in my sentry, and following the doc, I decide to perform a test, here goes the result:
raven test https://pubkey:[email protected]/13
Using DSN configuration:
https://pubkey:[email protected]/13
Client configuration:
base_url : https://sentry.mycomp.com
project : 13
public_key : pubkey
secret_key : seckey
Sending a test message... Event ID was '7598438b7a7f4479b6e7d7e875c36122'
Sentry responded with an error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)> (url: https://sentry.mycomp.com/api/13/store/)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1254, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1151, in _send_request
self.endheaders(body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 1102, in endheaders
self._send_output(message_body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/Users/liyx/projects/py_projects/telegraf-jenkins/venv/lib/python3.5/site-packages/raven/utils/http.py", line 38, in connect
sock, ca_certs=ca_certs, cert_reqs=ssl.CERT_REQUIRED)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 1069, in wrap_socket
ciphers=ciphers)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 752, in __init__
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 988, in do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py", line 633, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
It seems that this caused by the url https://sentry.mycomp.com/api/13/store/, so I tried to open it from the browser, then I got the following output:
{"error":"Unable to find authentication information"}
I am pretty sure that the SSL key for sentry is OK since I can perform a successful test by JavaScript.
Here goes the question:
- Why raven python try to access xx/api/project_num/store ?
- How to solve this .
Thanks for help in advance.
The following JavaScript demo works fine, that is it can produce an event to the sentry server.
<html>
<head>
<script src="https://cdn.ravenjs.com/3.17.0/raven.min.js" crossorigin="anonymous"></script>
<script type="text/javascript">
Raven.config('https://[email protected]/13').install()
try {
doSomething(a[0])
} catch(e) {
Raven.captureException(e)
}
</script>
</head>
</html>
facing the same issue with raven 6.4.0
I'm having the same error. Tried inside and outside of Docker.
Python version: 3.6.3 Operating system (outside Docker): Ubuntu 16.04 Operating system (inside Docker): Debian 9 (Stretch) Raven version: 6.9.0
Remote Sentry self-hosted, version: Sentry 8.22.0 HTTPS handling by Traefik 1.6, with certificates generated via Let's Encrypt
Minimum script to generate the error:
from raven import Client
client = Client('https://[email protected]/5?timeout=15')
client.captureException()
try:
1 / 0
except ZeroDivisionError:
client.captureException()
Executing it inside or outside Docker returns the error:
See full error log
Traceback (most recent call last):
File "backend/app/app/try_sentry.py", line 6, in <module>
client.captureException()
File "/home/user/.local/share/virtualenvs/custom-env/lib/python3.6/site-packages/raven/base.py", line 824, in captureException
'raven.events.Exception', exc_info=exc_info, **kwargs)
File "/home/user/.local/share/virtualenvs/custom-env/lib/python3.6/site-packages/raven/base.py", line 635, in capture
elif not self.should_capture(exc_info):
File "/home/user/.local/share/virtualenvs/custom-env/lib/python3.6/site-packages/raven/base.py", line 828, in should_capture
exc_name = '%s.%s' % (exc_type.__module__, exc_type.__name__)
AttributeError: 'NoneType' object has no attribute '__module__'
Sentry is attempting to send 1 pending error messages
Waiting up to 10 seconds
Press Ctrl-C to quit
Sentry responded with an error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)> (url: https://sentry.example.com/api/5/store/)
Traceback (most recent call last):
File "/home/user/miniconda3/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/home/user/miniconda3/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/home/user/miniconda3/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/home/user/miniconda3/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/user/miniconda3/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/home/user/miniconda3/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/home/user/.local/share/virtualenvs/custom-env/lib/python3.6/site-packages/raven/utils/http.py", line 38, in connect
sock, ca_certs=ca_certs, cert_reqs=ssl.CERT_REQUIRED)
File "/home/user/miniconda3/lib/python3.6/ssl.py", line 1149, in wrap_socket
ciphers=ciphers)
File "/home/user/miniconda3/lib/python3.6/ssl.py", line 814, in __init__
self.do_handshake()
File "/home/user/miniconda3/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/home/user/miniconda3/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/share/virtualenvs/custom-env/lib/python3.6/site-packages/raven/transport/threaded.py", line 165, in send_sync
super(ThreadedHTTPTransport, self).send(url, data, headers)
File "/home/user/.local/share/virtualenvs/custom-env/lib/python3.6/site-packages/raven/transport/http.py", line 43, in send
ca_certs=self.ca_certs,
File "/home/user/.local/share/virtualenvs/custom-env/lib/python3.6/site-packages/raven/utils/http.py", line 66, in urlopen
return opener.open(url, data, timeout)
File "/home/user/miniconda3/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/home/user/miniconda3/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/home/user/miniconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/home/user/.local/share/virtualenvs/custom-env/lib/python3.6/site-packages/raven/utils/http.py", line 46, in https_open
return self.do_open(ValidHTTPSConnection, req)
File "/home/user/miniconda3/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)>
["AttributeError: 'NoneType' object has no attribute '__module__'", ' File "app/try_sentry.py", line 6, in <module>', ' File "raven/base.py", line 824, in captureException', ' File "raven/base.py", line 635, in capture', ' File "raven/base.py", line 828, in should_capture']
A similar problem just appeared in one older project. Always worked in the past, now it crashes if trying to log something to sentry. It used raven 5.8.x, not sure if there was an update of openssl (server not managed by us). It uses python 3.4.3 on Debian Jessie. Updating raven to 6.9 solved it for me, I'm still curious what caused the problem.
also got problem same as @tiangolo , adding verify_ssl=0 to DSN is a workaround to solve this problem temporarily.
related
raven does not support SNI
https://github.com/getsentry/raven-python/issues/523
As a w/a you can use requests transport, it is better than just disable SSL validation:
from raven.transport.threaded_requests import ThreadedRequestsHTTPTransport
client = raven.Client(transport=ThreadedRequestsHTTPTransport)