title: ActionCable: Unable to find subscription with identifier
body: <p>We have a stack: Rails / ActionCable and pure javascript client (Chrome extension) on Websocket.</p>
  <p>When users visit same web pages extension should show them, that somebody else is currently here online. So the script sends the 'client' and 'page_id' parameters to the server in 'subscribe/unsubscribe'.</p>
  <pre><code>function connect(headers, pageId) {
  let params = Object.keys(headers).map(key =&gt; `${key}=${headers[key]}`).join('&amp;');
  webSocket = new WebSocket(`${CABLE_URL}?${params}`);
  return new Promise((resolve, reject) =&gt; {
      webSocket.onopen = () =&gt; {
          if (webSocket.readyState === WebSocket.OPEN) {
              const params = {channel: &quot;ExtensionConnectionChannel&quot;, client: headers.client, page_id: pageId};
              const message = {command: &quot;subscribe&quot;, identifier: JSON.stringify(params)};
              webSocket.send(JSON.stringify(message));
          }
          let message = webSocket.readyState === WebSocket.OPEN ? 'Connection established' : 'Connection not established';
          resolve(message);
      };
  });
  
  
  function closeHandler(headers, pageId) {
  if (webSocket.readyState === WebSocket.OPEN) {
      const params = {channel: &quot;ExtensionConnectionChannel&quot;, client: headers.client, page_id: pageId};
      const message = {command: &quot;unsubscribe&quot;, identifier: JSON.stringify(params)};
      webSocket.send(JSON.stringify(message));
  }}
  </code></pre>
  <p>When user closes the page client sent 'unsubscribe'. The problem is that unsubscription works fine only for the last signed identifier (established channel connection):</p>
  <pre><code>Unsubscribing from channel: {&quot;channel&quot;:&quot;ExtensionConnectionChannel&quot;,&quot;client&quot;:&quot;fpShbwi2L&quot;,&quot;page_id&quot;:&quot;123456789&quot;}
  </code></pre>
  <p>But if several identifiers are sent, previous identifiers are not unsubscribed:</p>
  <pre><code>Unsubscribing from channel: {&quot;channel&quot;:&quot;ExtensionConnectionChannel&quot;,&quot;client&quot;:&quot;fpShbwi2L&quot;,&quot;page_id&quot;:&quot;123456789&quot;}
  Could not execute command from ({&quot;command&quot;=&gt;&quot;unsubscribe&quot;, &quot;identifier&quot;=&gt;&quot;{\&quot;channel\&quot;:\&quot;ExtensionConnectionChannel\&quot;,\&quot;client\&quot;:\&quot;fpShbwi2L\&quot;,\&quot;page_id\&quot;:\&quot;123456789\&quot;}&quot;})
  [RuntimeError - Unable to find subscription with identifier: {&quot;channel&quot;:&quot;ExtensionConnectionChannel&quot;,&quot;client&quot;:&quot;fpShbwi2L&quot;,&quot;page_id&quot;:&quot;123456789&quot;}]
  </code></pre>
  <p>It looks like every new subscription with new 'client' and 'page_id' overwrites previous one, but I can't figure out how and why.</p>
  <p>The channel has a stream as a string:</p>
  <pre><code>class ExtensionConnectionChannel &lt; ApplicationCable::Channel
    def subscribed
      stream_from 'extension_connection'
    end
  
    def unsubscribed
      stop_stream_from 'extension_connection'
    end
  end
  </code></pre>
  <p>Please help. Thanks in advance.</p>