{"action":"opened","issue":{"url":"https://api.github.com/repos/django/channels/issues/860","repository_url":"https://api.github.com/repos/django/channels","labels_url":"https://api.github.com/repos/django/channels/issues/860/labels{/name}","comments_url":"https://api.github.com/repos/django/channels/issues/860/comments","events_url":"https://api.github.com/repos/django/channels/issues/860/events","html_url":"https://github.com/django/channels/issues/860","id":294374542,"number":860,"title":"method disconnect WebsocketConsumer won't trigger","user":{"login":"tsiaGeorge","id":6226079,"avatar_url":"https://avatars1.githubusercontent.com/u/6226079?v=4","gravatar_id":"","url":"https://api.github.com/users/tsiaGeorge","html_url":"https://github.com/tsiaGeorge","followers_url":"https://api.github.com/users/tsiaGeorge/followers","following_url":"https://api.github.com/users/tsiaGeorge/following{/other_user}","gists_url":"https://api.github.com/users/tsiaGeorge/gists{/gist_id}","starred_url":"https://api.github.com/users/tsiaGeorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsiaGeorge/subscriptions","organizations_url":"https://api.github.com/users/tsiaGeorge/orgs","repos_url":"https://api.github.com/users/tsiaGeorge/repos","events_url":"https://api.github.com/users/tsiaGeorge/events{/privacy}","received_events_url":"https://api.github.com/users/tsiaGeorge/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-05T12:23:01Z","updated_at":"2018-02-05T12:23:01Z","closed_at":null,"author_association":"NONE","body":"`disconnect` method won't be triggered when a websocket disconnects.\r\nHere is a simple Consumer:\r\n\r\n```\r\nfrom channels.generic.websocket import WebsocketConsumer\r\n\r\nclass TestConsumer(WebsocketConsumer):\r\n    def connect(self):\r\n        self.accept()\r\n        print('websocket instance connected')\r\n\r\n    def disconnect(self, message):\r\n        print('websocket instance disconnected')\r\n```\r\n\r\nReplicating the issue:\r\n- runserver:\r\n`./manage.py runserver -v 3`\r\n\r\n- Javascript console (connect websocket)\r\n`wbs = new WebSocket(\"ws://127.0.0.1:8000/test/\");`\r\n\r\n- runserver output\r\n```\r\n[2018/02/05 12:18:07] WebSocket HANDSHAKING /test/ [127.0.0.1:48306]\r\n2018-02-05 12:18:07,117 - DEBUG - http_protocol - Upgraded connection ['127.0.0.1', 48306] to WebSocket\r\nwebsocket connected\r\n2018-02-05 12:18:07,119 - DEBUG - ws_protocol - WebSocket ['127.0.0.1', 48306] open and established\r\n[2018/02/05 12:18:07] WebSocket CONNECT /test/ [127.0.0.1:48306]\r\n2018-02-05 12:18:07,119 - DEBUG - ws_protocol - WebSocket ['127.0.0.1', 48306] accepted by application\r\n```\r\n\r\n- Javascript console (close websocket)\r\n`wbs.close();`\r\n\r\n- runserver output\r\n```\r\n2018-02-05 12:19:33,103 - DEBUG - ws_protocol - WebSocket closed for ['127.0.0.1', 48306]\r\n[2018/02/05 12:19:33] WebSocket DISCONNECT /test/ [127.0.0.1:48306]\r\n```\r\n\r\nWebsocket properly disconnects but disconnect method hasn't been triggered in my consumer. "}}
{"actor":{"display_login":"tsiaGeorge"}}