{"action":"closed","issue":{"url":"https://api.github.com/repos/kanaka/websockify/issues/184","labels_url":"https://api.github.com/repos/kanaka/websockify/issues/184/labels{/name}","comments_url":"https://api.github.com/repos/kanaka/websockify/issues/184/comments","events_url":"https://api.github.com/repos/kanaka/websockify/issues/184/events","html_url":"https://github.com/kanaka/websockify/issues/184","id":94740569,"number":184,"title":"handler exception: WSRequestHandler instance has no attribute 'last_code  noVNC","user":{"login":"ramonmedeiros","id":950160,"avatar_url":"https://avatars.githubusercontent.com/u/950160?v=3","gravatar_id":"","url":"https://api.github.com/users/ramonmedeiros","html_url":"https://github.com/ramonmedeiros","followers_url":"https://api.github.com/users/ramonmedeiros/followers","following_url":"https://api.github.com/users/ramonmedeiros/following{/other_user}","gists_url":"https://api.github.com/users/ramonmedeiros/gists{/gist_id}","starred_url":"https://api.github.com/users/ramonmedeiros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramonmedeiros/subscriptions","organizations_url":"https://api.github.com/users/ramonmedeiros/orgs","repos_url":"https://api.github.com/users/ramonmedeiros/repos","events_url":"https://api.github.com/users/ramonmedeiros/events{/privacy}","received_events_url":"https://api.github.com/users/ramonmedeiros/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-13T14:57:31Z","updated_at":"2015-08-27T21:39:28Z","closed_at":"2015-08-27T21:39:28Z","body":"I got this issue while running kimchi (github.com/kimchi-project/kimchi, that uses python-websockify. Looking at the code, i saw the variable being reffered without checking it. The patch would be simple:\r\n\r\n```\r\ndiff --git a/usr/lib/python2.7/site-packages/websockify/websocket.py b/websocket.py\r\nindex 2475f99..1c07f53 100644\r\n--- a/usr/lib/python2.7/site-packages/websockify/websocket.py\r\n+++ b/websocket.py\r\n@@ -625,17 +625,20 @@ Sec-WebSocket-Accept: %s\\r\r\n \r\n         wsh = WSRequestHandler(retsock, address, not self.web, \r\n                                self.file_only, self.no_parent)\r\n-        if wsh.last_code == 101:\r\n-            # Continue on to handle WebSocket upgrade\r\n-            pass\r\n-        elif wsh.last_code == 405:\r\n-            raise self.EClose(\"Normal web request received but disallowed\")\r\n-        elif wsh.last_code < 200 or wsh.last_code >= 300:\r\n-            raise self.EClose(wsh.last_message)\r\n-        elif self.verbose:\r\n-            raise self.EClose(wsh.last_message)\r\n-        else:\r\n-            raise self.EClose(\"\")\r\n+\r\n+        if \"last_code\" in dir(wsh):\r\n+\r\n+            if wsh.last_code == 101:\r\n+                # Continue on to handle WebSocket upgrade\r\n+                pass\r\n+            elif wsh.last_code == 405:\r\n+                raise self.EClose(\"Normal web request received but disallowed\")\r\n+            elif wsh.last_code < 200 or wsh.last_code >= 300:\r\n+                raise self.EClose(wsh.last_message)\r\n+            elif self.verbose:\r\n+                raise self.EClose(wsh.last_message)\r\n+            else:\r\n+                raise self.EClose(\"\")\r\n \r\n         response = self.do_websocket_handshake(wsh.headers, wsh.path)\r\n```\r\n\r\n"}}