channels icon indicating copy to clipboard operation
channels copied to clipboard

Close code: 1011 (No logging)

Open dpineiden opened this issue 6 years ago • 4 comments

Hi.

I'm trying to configure channels, with redis layer, i'm well connected to the channels with a source-client. After some messages correctrly sended, the channel fails and cut the communication.

Send: 1011 close_code and no more information....

What can i do?

dpineiden avatar Nov 19 '19 10:11 dpineiden

Had very similar issue. What was happening for me was in our chat system, when sending a message, connection would close with error 1011 and no error in the logs. What was happening was right after sending, the server sends the message to other groups, which were based on the user-names, which caused the error :

  File "/home/tonis/Projects/lino/py3/lib/python3.7/site-packages/channels/layers.py", line 168, in valid_group_name
    "Group name must be a valid unicode string containing only ASCII "
  Group name must be a valid unicode string containing only ASCII alphanumerics, hyphens, or periods.

For some reason unknown to me it didn't actually log this error anywhere. But just crashed. solution was to wrap the channels sending code in a try block and use:

except Exception as E:
    logger.exception(e)

Then I could see the error. Hopfully this helps you or someone in the future.

TonisPiip avatar Feb 14 '20 11:02 TonisPiip

For some reason unknown to me it didn't actually log this error anywhere.

This is the first issue. It would be nice for this to bubble up. @CylonOven Could you put a minimal project together showing your set up so we can work out what would need to change there? (Ta!)

carltongibson avatar Feb 26 '20 17:02 carltongibson

The missing logs can be related to https://github.com/jazzband/django-debug-toolbar/issues/1300 Just configure a handler for the "daphne" logger in the meantime.

JulienPalard avatar Jul 20 '20 13:07 JulienPalard

Just wanted to contribute to this issue, how I caused it. ;) and fixed it.

I am using async. Its easy to forget you need to convert certain calls into @sync_to_async They will work SOMETIMES. So recommend you take special care when developing this code.. Drop some global try: exceptions in to catch the error and log.. As typically this will fail silently and with a 1011 error in the browser side.

jamiegau avatar Oct 14 '21 23:10 jamiegau