crossbario / crossbario/autobahn-python

WebSockeProtocol reasonRaw has no attribute 'encode' on closed socket

Open
#494 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.5k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

I noticed today that when my browser tab holding my ongoing ws was put to sleep (tab suspender extension for chrome) that the crossbar.io router raised an exception:

2015-09-09T17:01:03-0400 [Router       1306] Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/twisted/python/log.py", line 101, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python3.4/site-packages/twisted/python/log.py", line 84, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python3.4/site-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python3.4/site-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/usr/lib/python3.4/site-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib/python3.4/site-packages/twisted/internet/tcp.py", line 209, in doRead
    return self._dataReceived(data)
  File "/usr/lib/python3.4/site-packages/twisted/internet/tcp.py", line 215, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/usr/lib/python3.4/site-packages/autobahn-0.10.7-py3.4.egg/autobahn/twisted/websocket.py", line 135, in dataReceived
    self._dataReceived(data)
  File "/usr/lib/python3.4/site-packages/autobahn-0.10.7-py3.4.egg/autobahn/websocket/protocol.py", line 1313, in _dataReceived
    self.consumeData()
  File "/usr/lib/python3.4/site-packages/autobahn-0.10.7-py3.4.egg/autobahn/websocket/protocol.py", line 1328, in consumeData
    while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
  File "/usr/lib/python3.4/site-packages/autobahn-0.10.7-py3.4.egg/autobahn/websocket/protocol.py", line 1480, in processData
    return self.processDataHybi()
  File "/usr/lib/python3.4/site-packages/autobahn-0.10.7-py3.4.egg/autobahn/websocket/protocol.py", line 1791, in processDataHybi
    fr = self.onFrameEnd()
  File "/usr/lib/python3.4/site-packages/autobahn-0.10.7-py3.4.egg/autobahn/websocket/protocol.py", line 1889, in onFrameEnd
    self.processControlFrame()
  File "/usr/lib/python3.4/site-packages/autobahn-0.10.7-py3.4.egg/autobahn/websocket/protocol.py", line 1945, in processControlFrame
    if self.onCloseFrame(code, reasonRaw):
  File "/usr/lib/python3.4/site-packages/autobahn-0.10.7-py3.4.egg/autobahn/websocket/protocol.py", line 863, in onCloseFrame
    self.sendCloseFrame(code=code, reasonUtf8=reasonRaw.encode("UTF-8"), isReply=True)
builtins.AttributeError: 'NoneType' object has no attribute 'encode'

2015-09-09T17:01:03-0400 [Router       1306] Connection to/from tcp4:127.0.0.1:57025 lost (<class 'AttributeError'>): 'NoneType' object has no attribute 'encode')

This is autobahn 10.5. Please also note that I did add the option "echo_close_codereason":true to my crossbar.io config.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in autobahn/websocket/protocol.py at onCloseFrame and processControlFrame, following the traceback from autobahn/twisted/websocket.py. Reproduce the closed-socket path with echo_close_codereason enabled and inspect how an absent reason is handled. Done means the connection-close path no longer raises AttributeError when the reason is None.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.