diff --git a/docs/changelog.rst b/docs/changelog.rst index a9326933..b78a5942 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -32,6 +32,9 @@ Bug fix release. constant for use by implementors of :method:`mopidy.local.Library.browse`. (Related to: :issue:`833`) +- HTTP frontend: Guard against double close of WebSocket, which causes an + :exc:`AttributeError` on Tornado < 3.2. + v0.19.3 (2014-08-03) ==================== diff --git a/mopidy/http/handlers.py b/mopidy/http/handlers.py index e212c77d..3ef10c3b 100644 --- a/mopidy/http/handlers.py +++ b/mopidy/http/handlers.py @@ -110,7 +110,10 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler): self.request.remote_ip, response) except Exception as e: logger.error('WebSocket request error: %s', e) - self.close() + if self.ws_connection: + # Tornado 3.2+ checks if self.ws_connection is None before + # using it, but not older versions. + self.close() def check_origin(self, origin): # Allow cross-origin WebSocket connections, like Tornado before 4.0