question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'WebSocketProtocol' object has no attribute 'reply_channel'

See original GitHub issue

With an incorrect nginx setup (one that does not include proxy_set_header Connection "upgrade";) Daphne crashes resulting in a client-side 502 Bad gateway.

When the log statement from daphne/http_protocol.py:107 is removed Daphne no longer crashes resulting in a client-side 400 HTTP Connection headers do not include ‘upgrade’ value (case-insensitive) : close, which is more helpful in determining what is wrong with the setup.


Stacktrace:

2016-06-26 22:02:12,500 ERROR    Traceback (most recent call last):
  File "<...>/virtual/lib/python3.4/site-packages/daphne/http_protocol.py", line 107, in process
    logger.debug("Upgraded connection %s to WebSocket %s", self.reply_channel, protocol.reply_channel)
AttributeError: 'WebSocketProtocol' object has no attribute 'reply_channel'

Unhandled Error
Traceback (most recent call last):
  File "<...>/virtual/lib/python3.4/site-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "<...>/virtual/lib/python3.4/site-packages/twisted/python/log.py", line 84, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "<...>/virtual/lib/python3.4/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "<...>/virtual/lib/python3.4/site-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "<...>/virtual/lib/python3.4/site-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
    why = selectable.doRead()
  File "<...>/virtual/lib/python3.4/site-packages/twisted/internet/tcp.py", line 209, in doRead
    return self._dataReceived(data)
  File "<...>/virtual/lib/python3.4/site-packages/twisted/internet/tcp.py", line 215, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "<...>/virtual/lib/python3.4/site-packages/twisted/protocols/basic.py", line 571, in dataReceived
    why = self.lineReceived(line)
  File "<...>/virtual/lib/python3.4/site-packages/twisted/web/http.py", line 1692, in lineReceived
    self.allContentReceived()
  File "<...>/virtual/lib/python3.4/site-packages/twisted/web/http.py", line 1781, in allContentReceived
    req.requestReceived(command, path, version)
  File "<...>/virtual/lib/python3.4/site-packages/twisted/web/http.py", line 768, in requestReceived
    self.process()
  File "<...>/virtual/lib/python3.4/site-packages/daphne/http_protocol.py", line 147, in process
    self.basic_error(500, b"Internal Server Error", "HTTP processing error")
  File "<...>/virtual/lib/python3.4/site-packages/daphne/http_protocol.py", line 256, in basic_error
    }).encode("utf8"),
  File "<...>/virtual/lib/python3.4/site-packages/daphne/http_protocol.py", line 216, in serverResponse
    http.Request.write(self, message['content'])
  File "<...>/virtual/lib/python3.4/site-packages/twisted/web/http.py", line 951, in write
    self.transport.writeSequence(l)
builtins.AttributeError: 'NoneType' object has no attribute 'writeSequence'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewgodwincommented, Jun 28, 2016

Released in 0.13.1.

0reactions
alastairparagascommented, Jun 28, 2016

I have the same problem as well. Tested the fix, seems good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'WebSocketProtocol' object has no attribute ... - Stack Overflow
Above this error should be a list of paths and at the top of that paths are the real error. In my case...
Read more >
Exception inside application: 'WebSocketProtocol' object has ...
Got this during or just after the failure state I've been encountering in django/channels_redis#81: (sorry, there are two exceptions smashed ...
Read more >
Issue 44577: Probably defect in Python 3.7.11
Probably something is not good here now. ... instance: Traceback: <class 'AttributeError'>: 'NoneType' object has no attribute 'replace' ...
Read more >
Django Channels 2.0 channel_layer ("no current event loop"?)
Laughing Man. from celery import task from channels import Channel @task def getAFTreeTask(channel_name): tree = Request().cache_af_tree() ...
Read more >
[Solved]-Tests for Django Channels consumers - appsloveworld
This is because the name that you provide to the 'Channel' object represents the channel this message was received on. Check the init...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found