5

我正在尝试将 Pusher 插入到我已经很晚的 Rails 应用程序中。客户端工作正常 - 使用 Pusher Event Creator 触发所需的 javascript。但是服务器端不起作用:

在我的通知控制器中使用以下代码创建操作来测试:

Pusher.trigger('private-4','new_message', {:from => "christian", :subject => "hello"})

给出这个错误:

Pusher::AuthenticationError (Unknown auth_key):
  app/controllers/notifications_controller.rb:57:in `block in create'
  app/controllers/notifications_controller.rb:38:in `create'

(调试控制台中没有出现任何新内容)

我在开发环境中运行它。我已经在我的系统上测试了“推送/通知”示例应用程序,客户端和服务器都可以正常工作。

在 development.rb 中:

  # Pusher
  require 'pusher'

  Pusher.app_id = '{redacted}'
  Pusher.key    = '{redacted}'
  Pusher.secret = '{redacted}'

  Pusher.logger = Rails.logger

更新 - 完整的日志输出:

Unknown auth_key (Pusher::AuthenticationError)
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/pusher-0.11.3/lib/pusher/request.rb:99:in `handle_response'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/pusher-0.11.3/lib/pusher/request.rb:52:in `send_sync'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/pusher-0.11.3/lib/pusher/resource.rb:18:in `post'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/pusher-0.11.3/lib/pusher/client.rb:134:in `post'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/pusher-0.11.3/lib/pusher/client.rb:216:in `trigger'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/pusher-0.11.3/lib/pusher/channel.rb:59:in `trigger!'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/pusher-0.11.3/lib/pusher/channel.rb:71:in `trigger'
/Users/christian/Sites/casenexus/app/controllers/notifications_controller.rb:60:in `block in create'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/mime_responds.rb:270:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/mime_responds.rb:270:in `retrieve_collector_from_mimes'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/mime_responds.rb:194:in `respond_to'
/Users/christian/Sites/casenexus/app/controllers/notifications_controller.rb:40:in `create'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:447:in `_run__2723577406764024271__process_action__2755147847840742796__callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:17:in `process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/rescue.rb:29:in `process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `block in instrument'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `instrument'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.8/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/newrelic_rpm-3.6.1.87/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:38:in `block in process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/newrelic_rpm-3.6.1.87/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:318:in `perform_action_with_newrelic_trace'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/newrelic_rpm-3.6.1.87/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:37:in `process_action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:121:in `process'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/abstract_controller/rendering.rb:45:in `process'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal.rb:203:in `dispatch'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_controller/metal.rb:246:in `block in action'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:36:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:600:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:184:in `call!'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:164:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/newrelic_rpm-3.6.1.87/lib/new_relic/rack/error_collector.rb:12:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/newrelic_rpm-3.6.1.87/lib/new_relic/rack/agent_hooks.rb:18:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/newrelic_rpm-3.6.1.87/lib/new_relic/rack/browser_monitoring.rb:16:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/newrelic_rpm-3.6.1.87/lib/new_relic/rack/developer_mode.rb:28:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/head.rb:14:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/flash.rb:242:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/cookies.rb:339:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:64:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__2979100583981751168__call__3555748325778021510__callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/reloader.rb:65:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/rack/log_tailer.rb:17:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p392@rails3tutorial2ndEd/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
  Rendered layouts/_flash.html.haml (1.8ms)
  Rendered notifications/create.js.erb (4.3ms)
4

1 回答 1

17

感谢推送器的支持,解决方案是设置以下内容以及我的其他凭据:

Pusher.host = "api-eu.pusher.com"

...这是必需的,因为我的应用程序位于新的 EU Heroku 集群上,并且 pusher-gem 调用我的 pusher app_key/auth_key 无效的美国集群。

于 2013-06-01T08:53:27.043 回答