From d86d7dd3c4af43d4879b48b6852ec650b2304e88 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Thu, 16 Mar 2017 19:05:49 -0700 Subject: [PATCH] Fixed #93: Don't try to send disconnect if it never connected --- daphne/http_protocol.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/daphne/http_protocol.py b/daphne/http_protocol.py index 0645ea5..019a5ea 100755 --- a/daphne/http_protocol.py +++ b/daphne/http_protocol.py @@ -190,13 +190,15 @@ class WebRequest(http.Request): Sends a disconnect message on the http.disconnect channel. Useful only really for long-polling. """ - try: - self.factory.channel_layer.send("http.disconnect", { - "reply_channel": self.reply_channel, - "path": self.unquote(self.path), - }) - except self.factory.channel_layer.ChannelFull: - pass + # If we don't yet have a path, then don't send as we never opened. + if self.path: + try: + self.factory.channel_layer.send("http.disconnect", { + "reply_channel": self.reply_channel, + "path": self.unquote(self.path), + }) + except self.factory.channel_layer.ChannelFull: + pass def connectionLost(self, reason): """