{"action":"opened","issue":{"url":"https://api.github.com/repos/rails/rails/issues/25761","repository_url":"https://api.github.com/repos/rails/rails","labels_url":"https://api.github.com/repos/rails/rails/issues/25761/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/25761/comments","events_url":"https://api.github.com/repos/rails/rails/issues/25761/events","html_url":"https://github.com/rails/rails/issues/25761","id":164671091,"number":25761,"title":"Uncaught Error: Existing connection must be closed before opening bug","user":{"login":"tarungarg","id":5187228,"avatar_url":"https://avatars.githubusercontent.com/u/5187228?v=3","gravatar_id":"","url":"https://api.github.com/users/tarungarg","html_url":"https://github.com/tarungarg","followers_url":"https://api.github.com/users/tarungarg/followers","following_url":"https://api.github.com/users/tarungarg/following{/other_user}","gists_url":"https://api.github.com/users/tarungarg/gists{/gist_id}","starred_url":"https://api.github.com/users/tarungarg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarungarg/subscriptions","organizations_url":"https://api.github.com/users/tarungarg/orgs","repos_url":"https://api.github.com/users/tarungarg/repos","events_url":"https://api.github.com/users/tarungarg/events{/privacy}","received_events_url":"https://api.github.com/users/tarungarg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-09T15:15:50Z","updated_at":"2016-07-09T15:15:50Z","closed_at":null,"body":"Actioncable is implemented on too many places in my application. Getting this error most of times \r\n**Existing connection must be closed before opening bug**\r\n\r\nAs per my assumption, this error comes if i visits the same page more than once (where actioncable is implemented). Actioncable creates new connection every time.\r\nSo my question is  \r\nHow can i close the running connections if they are not using. Also if i visit the page where actioncable is implemented more than once, the first/prev. connection must be close.  \r\n\r\nSome other information:-\r\nI implemented actioncable where ajax was using. Typed messages were duplicating more than once. Like events('received' method of actioncable) were binding again and again, as i was visiting the page. For eg. if I had visited the page 3 times and when i typed the message \"Hi\". \"Hi\" was showing 3 times on the page. I got some interesting result when i tried to debug. I ran below command       \r\n\r\n> chat_obj.cable.subscriptions.subscriptions\r\n\r\nI got array of subscriptions with duplicate identifiers. I tried to close subscriptions with below command \r\n\r\n>   for (var i=0; i <= chat_obj.cable.subscriptions.subscriptions.length; i++) {\r\n>       chat_obj.cable.subscriptions.remove(chat_obj.cable.subscriptions.subscriptions[i+1])\r\n>   }\r\n\r\nbut i got some unexpected behavior of actioncable. Messages were not delivering sometime.\r\n\r\n`Could not execute command from {\"command\"=>\"unsubscribe\", \"identifier\"=>\"{\\\"channel\\\":\\\"DeleteMessageChannel\\\"}\"}) [NoMethodError - undefined method `unsubscribe_from_channel' for nil:NilClass]: /home/tarungarg/.rvm/gems/ruby-2.3.1/bundler/gems/actioncable-92adbc2fab09/lib/action_cable/connection/subscriptions.rb:44:in `remove_subscription' | /home/tarungarg/.rvm/gems/ruby-2.3.1/bundler/gems/actioncable-92adbc2fab09/lib/action_cable/connection/subscriptions.rb:40:in `remove' | /home/tarungarg/.rvm/gems/ruby-2.3.1/bundler/gems/actioncable-92adbc2fab09/lib/action_cable/connection/subscriptions.rb:16:in `execute_command' | /home/tarungarg/.rvm/gems/ruby-2.3.1/bundler/gems/actioncable-92adbc2fab09/lib/action_cable/connection/base.rb:88:in `receive' | /home/tarungarg/.rvm/gems/ruby-2.3.1/bundler/gems/actioncable-92adbc2fab09/lib/action_cable/server/worker.rb:19:in `block in invoke\r\n`\r\n### Actual behavior\r\nIt should automatically find for the identifier and should not create new one if identifier already exists.\r\n\r\n### System configuration\r\nRails 4.2.6\r\nRuby 2.3.1p112\r\n"}}
{"actor":{"display_login":"tarungarg"}}