anycable / anycable-rails

AnyCable for Ruby on Rails applications
https://anycable.io
MIT License
497 stars 35 forks source link

ActionController::RoutingError (No route matches [GET] "/cable"): hot-wire / Rails 6 #146

Closed RailsCod3rFuture closed 3 years ago

RailsCod3rFuture commented 3 years ago

To begin, anycable is running - yet rails is still searching for "/cable" route. I don't know if this has been tested with hot-wire. So, I wanted to keep it short and sweet. Can someone look into this issue - I am unable to try the new features.

palkan commented 3 years ago

Have you specified config.action_cable.url to point to anycavle-go server?

RailsCod3rFuture commented 3 years ago

my development.rb has the below in it

 config.after_initialize do
    config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL", "ws://localhost:3334/cable") if AnyCable::Rails.enabled?
  end

output for anycable

Broadcasting Redis channel: __anycable__
RPC server is starting
RPC server is listening on 127.0.0.1:5001

...

RPC controller initialized: localhost:5001 (concurrency: 28, proto_versions: v0,v1)
Subscribed to Redis channel: __anycable__
RailsCod3rFuture commented 3 years ago

When I add back mount ActionCable.server => '/cable' to routes.rb I get "You're trying to connect to Action Cable server while using Anycable."

palkan commented 3 years ago

Could you check your action cable meta tag in the HTML contents of the page?

Which JS library do you use?

RailsCod3rFuture commented 3 years ago

In my responses, I get turbo-aca352d862899e…573c2e56213.js:2867 WebSocket connection to 'ws://127.0.0.1:3000/cable' failed: Error during WebSocket handshake: Unexpected response code: 404

RailsCod3rFuture commented 3 years ago

HTML header

<turbo-cable-stream-source channel="Turbo::StreamsChannel" signed-stream-name="IloybGtPaTh2Y21WemRXMWxMV1oxZEhWeVpTMXVaWGgwTDBOdmJuWmxjbk5oZEdsdmJpOHgi--65df3f25d2df99bd867b8e6adf7432a7ee91a12dfa0f0904"></turbo-cable-stream-source>

palkan commented 3 years ago

I mean action_cable_meta_tag. Do you have it in your layout?

RailsCod3rFuture commented 3 years ago

No, I don't have that in my header section; actually.

 <head>
    <!--
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-1333455-1"></script>
    -->
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <%= javascript_include_tag 'analytics', async: true %>

    <title>Test App</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>

    <%= stylesheet_link_tag 'application', media: 'all' %>
    <%= javascript_pack_tag 'application' %>
    <%= javascript_include_tag 'https://cdn.jsdelivr.net/npm/spectrum-colorpicker2/dist/spectrum.min.js' %>

    <link href="//fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i" rel="stylesheet">
    <%= yield :head %>
    <%= turbo_include_tags %>
    <%= stimulus_include_tags %>

  </head>
palkan commented 3 years ago

Then you should add it and propose a PR to turbo-rails to insert this helper during the installation as well (here 🙂)

RailsCod3rFuture commented 3 years ago

It seems to be working now - but there's an issue related to turbo that I will bring to their attention. Thanks