{"action":"created","issue":{"url":"https://api.github.com/repos/andrewgodwin/daphne/issues/18","repository_url":"https://api.github.com/repos/andrewgodwin/daphne","labels_url":"https://api.github.com/repos/andrewgodwin/daphne/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/andrewgodwin/daphne/issues/18/comments","events_url":"https://api.github.com/repos/andrewgodwin/daphne/issues/18/events","html_url":"https://github.com/andrewgodwin/daphne/issues/18","id":159873584,"number":18,"title":"Drop ws connection on ChannelFull","user":{"login":"ostcar","id":977937,"avatar_url":"https://avatars.githubusercontent.com/u/977937?v=3","gravatar_id":"","url":"https://api.github.com/users/ostcar","html_url":"https://github.com/ostcar","followers_url":"https://api.github.com/users/ostcar/followers","following_url":"https://api.github.com/users/ostcar/following{/other_user}","gists_url":"https://api.github.com/users/ostcar/gists{/gist_id}","starred_url":"https://api.github.com/users/ostcar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ostcar/subscriptions","organizations_url":"https://api.github.com/users/ostcar/orgs","repos_url":"https://api.github.com/users/ostcar/repos","events_url":"https://api.github.com/users/ostcar/events{/privacy}","received_events_url":"https://api.github.com/users/ostcar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-13T05:01:06Z","updated_at":"2016-06-14T06:25:01Z","closed_at":"2016-06-13T10:31:13Z","body":"In the current master, ```ws_protocoll.WebSocketProtocol.onOpen``` has the following code:\r\n\r\n```python\r\n        try:\r\n            self.channel_layer.send(\"websocket.connect\", self.request_info)\r\n        except self.channel_layer.ChannelFull:\r\n            # We don't drop the connection here as you don't _have_ to consume websocket.connect\r\n            pass\r\n```\r\nThis means, that if (for any reason) the Channel Layer is full, ```websocket.connect``` is not called for this connection. But the only way (I know of) to track a websocket connection is to write some code like this:\r\n```python\r\nchannel_routing = [\r\n    route(\"websocket.connect\", ws_add),\r\n]\r\n\r\n# Connected to websocket.connect\r\ndef ws_add(message):\r\n    Group(\"chat\").add(message.reply_channel)\r\n```\r\nSo if ```ChannelFull``` is raised when a connection is created, there is an open websocket connection, which the Django-app does not know of and probably wont send any message. The client has no way to know, that he has an untracked websocket connection.\r\n\r\nTherefore I would suggest that the try except block in the code above is removed. Then, if ```ChannelFull``` is raised, the websocket connection is closed. Therefore the client can try to open a new connection, which maybe has more luck. Or the client could show a warning to the user."},"comment":{"url":"https://api.github.com/repos/andrewgodwin/daphne/issues/comments/225790547","html_url":"https://github.com/andrewgodwin/daphne/issues/18#issuecomment-225790547","issue_url":"https://api.github.com/repos/andrewgodwin/daphne/issues/18","id":225790547,"user":{"login":"ostcar","id":977937,"avatar_url":"https://avatars.githubusercontent.com/u/977937?v=3","gravatar_id":"","url":"https://api.github.com/users/ostcar","html_url":"https://github.com/ostcar","followers_url":"https://api.github.com/users/ostcar/followers","following_url":"https://api.github.com/users/ostcar/following{/other_user}","gists_url":"https://api.github.com/users/ostcar/gists{/gist_id}","starred_url":"https://api.github.com/users/ostcar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ostcar/subscriptions","organizations_url":"https://api.github.com/users/ostcar/orgs","repos_url":"https://api.github.com/users/ostcar/repos","events_url":"https://api.github.com/users/ostcar/events{/privacy}","received_events_url":"https://api.github.com/users/ostcar/received_events","type":"User","site_admin":false},"created_at":"2016-06-14T06:25:01Z","updated_at":"2016-06-14T06:25:01Z","body":"Don't you think that the current behaviour can be a problem? How would you solve it?\r\n\r\nDaphne has all information to know, if there is a consumer against ```websocket.connect```. The following code seems to work:\r\n```python\r\n        from channels.message import Message\r\n        message = Message(self.request_info, \"websocket.connect\", self.channel_layer)\r\n        if self.channel_layer.router.match(message):\r\n            self.channel_layer.send(\"websocket.connect\", self.request_info)\r\n```\r\n\r\nA more general solution would be, if ```channel_layer.send()``` would raise a specific exception, if there is not consumer for the message. But therefore the channel_layer has to be initialized with the routing object. Currently only the ```ChannelLayerWrapper``` knows about the router."}}
{"actor":{"display_login":"ostcar"}}