Closed tambakoo closed 4 years ago
Hey!
Do you use the action_cable_meta_tag
helper in your HTML? And if yes, is it called before the JS script is loaded?
Action Cable uses meta
tags (set by action_cable_meta_tag
) to get the value of config.action_cable.url
(NOTE: it is action_cable.url not action_cable_url).
Hey!
Do you use the
action_cable_meta_tag
helper in your HTML? And if yes, is it called before the JS script is loaded?Action Cable uses
meta
tags (set byaction_cable_meta_tag
) to get the value ofconfig.action_cable.url
(NOTE: it is action_cable.url not action_cable_url).
This is how my application.html.erb
looks like -
<!DOCTYPE html>
<html>
<head>
<title>CapApi</title>
<%= action_cable_meta_tag %>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
action_cable.url
. It's written correctly on the code. Thanks!
And what do you see in the rendered HTML then? Does it contain the valid link (localhost:3334
)?
Thanks!
And what do you see in the rendered HTML then? Does it contain the valid link (
localhost:3334
)?
yes there is a <meta name="action-cable-url" content="ws://localhost:3334/cable">
on the rendered HTML.
The only suggestion is to debug the JS createConsumer
function and see where it gets the URL from if it’s not provided. It should be from the meta tag 🤷🏻♂️
Environment ruby 2.5.0p0 Rails 6.0.0.rc2 AnyCable v0.6.4 anycable-rails (0.6.5) grpc (1.27.0)
I set up anycable using the official documentation but I kept getting a
ActionController::RoutingError (No route matches [GET] "/cable"):
. The url being knocked on wasws://localhost:3000/cable
while the anycable-go websocket server is running on port 3334. I use webpacker on this app. This routing error is only fixed when in theapp/javascript/channels/consumer.js
I usethat is, explicitly declare the url while creating the consumer.
It does not matter if I remove the
config.action_cable_url
fromdevelopment.rb
which is very weird. This is clearly a case of overwritten configuration.This error was not resolved by #88 or #41. Does this look like a webpacker problem ? Please tell me what files will be relevant to debug this.