raven-python icon indicating copy to clipboard operation
raven-python copied to clipboard

Sentry integration with Channels-Daphne ERROR 500

Open vcajes opened this issue 7 years ago • 2 comments

Daphne is the recommended WebServer to run the channels library for WebSockets with Django. The way to deploy daphne is by using this asgi.py file (see: https://channels.readthedocs.io/en/latest/deploying.html)

The versions I am using:

  • Daphne: 2.2.0
  • Channels: 2.1.2
  • Raven Python: 6.9.0
import os
import django
from channels.routing import get_default_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
django.setup()
application = get_default_application()

But once I follow the sentry integration with Django tutorial and I wrap the channel's get_default_application() with the Sentry application wrapper:

import os
import django
from channels.routing import get_default_application
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
django.setup()
application = Sentry(get_default_application())

Daphne starts returning Error 500 to all requests:

<html> <head> <title>500 Internal Server Error</title> <style> body { font-family: sans-serif; margin: 0; padding: 0; } h1 { padding: 0.6em 0 0.2em 20px; color: #896868; margin: 0; } p { padding: 0 0 0.3em 20px; margin: 0; } footer { padding: 1em 0 0.3em 20px; color: #999; font-size: 80%; font-style: italic; } </style> </head> <body> <h1>500 Internal Server Error</h1> <p>Daphne HTTP processing error</p> <footer>Daphne</footer> </body> </html>

Without the Sentry wrapper, Channels/Daphne works well. Any workarounds? Solutions? Thanks!

vcajes avatar Jun 19 '18 20:06 vcajes

Might be way off the mark with this but could it be that Daphne is ASGI and Sentry is for WSGI?

ro5k0 avatar Aug 23 '18 13:08 ro5k0

Sentry supports Tornado using the raven.contrib.tornado.AsyncSentryClient -- I'm sure something like that could be written for ASGI support?

berislavlopac avatar Sep 20 '18 09:09 berislavlopac