Search code examples
ruby-on-railsactioncable

In rails with action cable. Subscription class not found "AsdfChannel". (But that's a channel from an old project!)


When I make a fresh program

~/myrubythings$ rails new channeltest3 
....

~/myrubythings$ cd channeltest3

~/myrubythings/channeltest3$ rails generate channel cvbnm
Running via Spring preloader in process 2837
      create  app/channels/cvbnm_channel.rb
   identical  app/assets/javascripts/cable.js
      create  app/assets/javascripts/channels/cvbnm.coffee
~/myrubythings/channeltest3$ rails s
=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.5.0-p0), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/cable" for 127.0.0.1 at 2019-04-21 02:15:56 +0100
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2019-04-21 02:15:56 +0100
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
Subscription class not found: "AsdfChannel"
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2019-04-21 02:16:00 +0100 ===
- Goodbye!
Exiting

Notice I get this message Subscription class not found: "AsdfChannel"

~/myrubythings/channeltest3$ grep -irl asdf ./
.//log/development.log
~/myrubythings/channeltest3$ 

~/myrubythings/channeltest3$ grep -i asdf log/development.log 
Subscription class not found: "AsdfChannel"
~/myrubythings/channeltest3$ 

The only file in this brand new project that even mentions AsdfChannel is the log file of the server!

It is picking up a channel from a project I was working on previously (channtest2)

~/myrubythings/channtest2$ grep -irl AsdfChannel ./
.//app/assets/javascripts/channels/asdf.coffee
.//app/channels/asdf_channel.rb
....

But my current project (channeltest3), has no mention of AsdfChannel, or asdf_channel.rb

I checked Subscription class not found 'MyChannel' in ActionCable and it mentioned to check that the channel's rb file is in app/channels (as it should be) and not a subdirectory of it. And it is in app/channels.

~/myrubythings/channeltest3$ ls app/channels/
application_cable   cvbnm_channel.rb
~/myrubythings/channeltest3$ 

Why would my server log be even mentioning a channel from a previous project. Should it be? And how can I properly kill off the channel from my previous project so that my new project doesn't mention it?

By the way, it doesn't stop me from broadcasting from server to client (from the channel of my current project, when I add code to do so), but that message I get still seems like a strange error to me.


Solution

  • It turns out that I had a tab open from an old project that used actioncable and even though I had closed the server, and started a new tab for the current running server, the old tab being open was still having an effect.

    The solution was to close all the tabs I had open that were at 127.0.0.1:3000, and only open such a tab/tabs after the server starts.