From 6679b8dfdf9af8349298f665c2e914f1f48a0616 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Mon, 27 Jun 2016 16:41:48 -0700 Subject: [PATCH] Fixed #28: Logging breaking bad WebSocket error messages --- daphne/http_protocol.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daphne/http_protocol.py b/daphne/http_protocol.py index 673ee6a..c9a147a 100755 --- a/daphne/http_protocol.py +++ b/daphne/http_protocol.py @@ -104,7 +104,10 @@ class WebRequest(http.Request): data += self.content.read() protocol.dataReceived(data) # Remove our HTTP reply channel association - logger.debug("Upgraded connection %s to WebSocket %s", self.reply_channel, protocol.reply_channel) + if hasattr(protocol, "reply_channel"): + logger.debug("Upgraded connection %s to WebSocket %s", self.reply_channel, protocol.reply_channel) + else: + logger.debug("Connection %s did not get successful WS handshake.", self.reply_channel) del self.factory.reply_protocols[self.reply_channel] self.reply_channel = None # Boring old HTTP.