channels: Cant see traceback
class FooConsumer(SyncConsumer):
def connect(self):
assert False
...
produces
WebSocket HANDSHAKING /foo/ [127.0.0.1:00000]
WebSocket DISCONNECT /foo/ [127.0.0.1:00000]
With no traceback
python==3.6.8
django==1.11.16
channels==2.2.0
daphne==2.1.0
channels-redis==2.1.1
asgi-redis==1.4.3
asgiref==2.2.0
macOS Mojave 10.14.1
When I try to reproduce this with a minimal setup, it gives traceback
Exception inside application:
File "/path/to/django_sandbox/venv/lib/python3.6/site-packages/channels/sessions.py", line 183, in __call__
...
File "/path/to/django_sandbox/foo/consumers.py", line 7, in connect
assert False
as expected.
Adding a print
logger.error("Exception inside application: %s", exception_output)
print(exception_output)
inside
daphne.server.Server.application_checker
allows me to see the output, so it seems daphne swallows the errors somehow.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 23 (3 by maintainers)
Commits related to this issue
- chore: remove debug toolbar Doesn't play nice with django channels Silences exceptions in consumers See: https://github.com/django/channels/issues/1340 https://github.com/django/channels/issues/1193 ... — committed to dimadk24/english-fight by dimadk24 3 years ago
- chore: remove debug toolbar Doesn't play nice with django channels Silences exceptions in consumers See: https://github.com/django/channels/issues/1340 https://github.com/django/channels/issues/1193 ... — committed to dimadk24/english-fight by dimadk24 3 years ago
- chore: remove debug toolbar Doesn't play nice with django channels Silences exceptions in consumers See: https://github.com/django/channels/issues/1340 https://github.com/django/channels/issues/1193 ... — committed to dimadk24/english-fight by dimadk24 3 years ago
- chore: remove debug toolbar Doesn't play nice with django channels Silences exceptions in consumers See: https://github.com/django/channels/issues/1340 https://github.com/django/channels/issues/1193 ... — committed to dimadk24/english-fight by dimadk24 3 years ago
Hey guys š ,
I think I found whatās the issue š„ š
So, what I did:
django-debug-toolbar
was causing the issue in our case š¦ So itās not a channels issueI searched in the other issues and found this - https://github.com/django/channels/issues/1193 (thereās a suggested quickfix there)
I started debugging the django-debug-toolbar code to find the root of the problem and turned out that this class is causing it - https://github.com/jazzband/django-debug-toolbar/blob/87eb27ffb2d0aea60b8b139360ece4d9fc91b47e/debug_toolbar/utils.py#L222
Itās used by a code hooked to the python logging module and collects only the logs from the current thread (which channels is not part from) š
https://github.com/django/channels/issues/1340#issuecomment-539957522 - this was solving the problem because the
print
is forcing a message to the standart output rather than using the python logging moduleHope this will help someone ^
Same here
backend:
frontend:
Weāre not using the debug toolbar. However, it certainly could be an issue with other middleware.
+1 have problem
Hi @Ivo-Donchev ā Thanks for the follow-up! Super. (Iāll leave this open for now, because I want to step through it myself when I have the moment.)
OK, so thereās clearly logging lacking here.
Question: if you dig-in, or use @Ivo-Donchevās suggestion, where are the errors occurring? Can we add logging in the right places there to surface the issues?
(Anyone want to put together a minimal project that replicates this that we can play with?)
We just ran into a comparable issue. On a test system, it was due to a missing HOSTS entry for the Redis server. Weāre seeing the same behavior on a prototype production system but it sounds like what weāre seeing is so non-specific that the actual error could be pretty much anything in the consumer.
EDIT: To be clear, weāre getting the slightly more interesting:
EDIT2: In our prototype production instance (AWS), the problem was that TransitEncyption defaults to ātrueā in the Elasticache Redis template we were using. We werenāt using
rediss://
and were accessing the server using a CNAME that didnāt match the certificate.Obviously, the details are less important than the fact that none of these error are bubbling up into logging (Django or otherwise).
Iām having the same issue: if anything inside the socket fails thereās no stacktrace in the logs.
@LukenAgile42 Weāve implemented a really simple class decorator (just for easier debugging locally) that basically catches any exception inside the current class and prints the stacktrace:
However it would be great if someone take a look ! š