anycable-rails: ArgumentError (wrong number of arguments (given 2, expected 1))
Hello,
Please let me know the solution, So I will update the code as well I have follow this links https://github.com/anycable/anycable-rails
ArgumentError (wrong number of arguments (given 2, expected 1)):
anycable-rails (0.5.0) lib/anycable/rails/actioncable/connection.rb:29:in initialize' actioncable (5.0.6) lib/action_cable/server/base.rb:28:in
new’
actioncable (5.0.6) lib/action_cable/server/base.rb:28:in call' actionpack (5.0.6) lib/action_dispatch/routing/mapper.rb:17:in
block in class:Constraints’
actionpack (5.0.6) lib/action_dispatch/routing/mapper.rb:46:in serve' actionpack (5.0.6) lib/action_dispatch/journey/router.rb:39:in
block in serve’
actionpack (5.0.6) lib/action_dispatch/journey/router.rb:26:in each' actionpack (5.0.6) lib/action_dispatch/journey/router.rb:26:in
serve’
actionpack (5.0.6) lib/action_dispatch/routing/route_set.rb:727:in call' warden (1.2.7) lib/warden/manager.rb:36:in
block in call’
warden (1.2.7) lib/warden/manager.rb:35:in catch' warden (1.2.7) lib/warden/manager.rb:35:in
call’
rack (2.0.3) lib/rack/etag.rb:25:in call' rack (2.0.3) lib/rack/conditional_get.rb:25:in
call’
rack (2.0.3) lib/rack/head.rb:12:in call' rack (2.0.3) lib/rack/session/abstract/id.rb:232:in
context’
rack (2.0.3) lib/rack/session/abstract/id.rb:226:in call' actionpack (5.0.6) lib/action_dispatch/middleware/cookies.rb:613:in
call’
activerecord (5.0.6) lib/active_record/migration.rb:553:in call' actionpack (5.0.6) lib/action_dispatch/middleware/callbacks.rb:38:in
block in call’
activesupport (5.0.6) lib/active_support/callbacks.rb:97:in __run_callbacks__' activesupport (5.0.6) lib/active_support/callbacks.rb:750:in
_run_call_callbacks’
activesupport (5.0.6) lib/active_support/callbacks.rb:90:in run_callbacks' actionpack (5.0.6) lib/action_dispatch/middleware/callbacks.rb:36:in
call’
actionpack (5.0.6) lib/action_dispatch/middleware/executor.rb:12:in call' actionpack (5.0.6) lib/action_dispatch/middleware/remote_ip.rb:79:in
call’
actionpack (5.0.6) lib/action_dispatch/middleware/debug_exceptions.rb:49:in call' web-console (3.5.1) lib/web_console/middleware.rb:135:in
call_app’
web-console (3.5.1) lib/web_console/middleware.rb:28:in block in call' web-console (3.5.1) lib/web_console/middleware.rb:18:in
catch’
web-console (3.5.1) lib/web_console/middleware.rb:18:in call' actionpack (5.0.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in
call’
railties (5.0.6) lib/rails/rack/logger.rb:36:in call_app' railties (5.0.6) lib/rails/rack/logger.rb:24:in
block in call’
activesupport (5.0.6) lib/active_support/tagged_logging.rb:69:in block in tagged' activesupport (5.0.6) lib/active_support/tagged_logging.rb:26:in
tagged’
activesupport (5.0.6) lib/active_support/tagged_logging.rb:69:in tagged' railties (5.0.6) lib/rails/rack/logger.rb:24:in
call’
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in call' actionpack (5.0.6) lib/action_dispatch/middleware/request_id.rb:24:in
call’
rack (2.0.3) lib/rack/method_override.rb:22:in call' rack (2.0.3) lib/rack/runtime.rb:22:in
call’
activesupport (5.0.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call' actionpack (5.0.6) lib/action_dispatch/middleware/executor.rb:12:in
call’
actionpack (5.0.6) lib/action_dispatch/middleware/static.rb:136:in call' rack (2.0.3) lib/rack/sendfile.rb:111:in
call’
railties (5.0.6) lib/rails/engine.rb:522:in call' puma (3.11.0) lib/puma/configuration.rb:225:in
call’
puma (3.11.0) lib/puma/server.rb:624:in handle_request' puma (3.11.0) lib/puma/server.rb:438:in
process_client’
puma (3.11.0) lib/puma/server.rb:302:in block in run' puma (3.11.0) lib/puma/thread_pool.rb:120:in
block in spawn_thread’
Rendering /home/yuva/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
Rendering /home/yuva/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
Rendered /home/yuva/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (3.1ms)
Rendering /home/yuva/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
Rendered /home/yuva/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.3ms)
Rendering /home/yuva/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
Rendered /home/yuva/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.3ms)
Rendered /home/yuva/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (23.3ms)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 36 (16 by maintainers)
@Crashtor Can you show me the logs for RPC app? Usually, 502 means that something went wrong with proxy (Heroku router?). There should be errors in the log.
You don’t need this in your
routes.rb
(that explains the initial problem – connecting to the Rails Action Cable server). Rails automatically mounts Action Cable ifconfig.action_cable.mount_path
is notnil
.Do you set
cookies[:username]
somewhere in your code? Or have your tried to runanycable_demo
app (we have such cookies usage there)? Probably, just a cookie left from something else. Have you tried to clear the browser cookies?@birthdaycorp
What’s in your
ApplicationCable::Connection#connect
?It’s a part of the cookies.
Good catch!
I’d suggest to create consumer on DOM load event instead, no reason to initiate the connection before the page is ready.
Try to run
anycable-go
with-debug
flag and check logs. Probably, authentication problem or RPC server is not running (bundle exec anycable
).@birthdaycorp Are you sure that the meta tag is shown on the page which invokes WS connect and? Check all layouts for
action_cable_meta_tag
.@birthdaycorp What shows the meta tag when you set
config.action_cable.url = 'ws://localhost:3334/cable'
? Does it still point to"ws://localhost:3000/cable"
?Where do you set
config.action_cable.url
:config/application.rb
orconfig/environments/development.rb
?@birthdaycorp If you want to use AnyCable in all environments including development, make sure that you set
config.action_cable.url
andws server is running. Nothing related to ActionCable in routes is necessary.Can you describe what happens when you do all of that?
@birthdaycorp If it reaches Rails’s router, it means that
config.action_cable.url
is not properly set for the corresponding environment. When AnyCable is used, your frontend should reach websocket backend directly.Just to make sure, that this option is set and passed properly, check
action-cable-url
meta tag on a page.@CR4567 Hm, when using AnyCable
allowed_request_origins
is not used.The path is missing as I see, should be:
"ws://URL:PORT/cable"
I also hit this today! I followed the steps in the anycable-rails README and encountered a very similar similar stacktrace when I ran it on these 2 combinations of versions:
anycable (0.4.6), anycable-rails (0.4.7), and rails (5.1.0.rc1)
anycable (0.5.0), anycable-rails (0.5.0), and rails (5.1.0.rc1)
It might just be that the README is a little out of date? I’m going to keep poking around.