2013-05-26 36 views
6

Tôi đang cố gắng chèn Pusher vào ứng dụng Rails giai đoạn đã khá muộn của tôi. Phía máy khách hoạt động tốt - bằng cách sử dụng Trình tạo sự kiện Pusher kích hoạt javascript mong muốn. Phía máy chủ không hoạt động tuy nhiên:Pusher trong Rails: "Unknown auth_key" - phía máy chủ không kích hoạt sự kiện

Sử dụng đoạn mã sau vào bộ điều khiển thông báo của tôi tạo ra hành động để kiểm tra:

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

Cung cấp cho lỗi này:

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

(và không có gì xuất hiện mới trong Bàn điều khiển gỡ lỗi)

Tôi đang chạy điều này trong môi trường phát triển. Tôi đã thử nghiệm ứng dụng mẫu 'pusher/notify' trên hệ thống của tôi và hoạt động tốt, cả máy khách và máy chủ.

trong development.rb:

# Pusher 
    require 'pusher' 

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

    Pusher.logger = Rails.logger 

Cập nhật - đầy đủ log đầu ra:

Unknown auth_key (Pusher::AuthenticationError) 
/usr/local/rvm/gems/[email protected]/gems/pusher-0.11.3/lib/pusher/request.rb:99:in `handle_response' 
/usr/local/rvm/gems/[email protected]/gems/pusher-0.11.3/lib/pusher/request.rb:52:in `send_sync' 
/usr/local/rvm/gems/[email protected]/gems/pusher-0.11.3/lib/pusher/resource.rb:18:in `post' 
/usr/local/rvm/gems/[email protected]/gems/pusher-0.11.3/lib/pusher/client.rb:134:in `post' 
/usr/local/rvm/gems/[email protected]/gems/pusher-0.11.3/lib/pusher/client.rb:216:in `trigger' 
/usr/local/rvm/gems/[email protected]/gems/pusher-0.11.3/lib/pusher/channel.rb:59:in `trigger!' 
/usr/local/rvm/gems/[email protected]/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/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/mime_responds.rb:270:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/mime_responds.rb:270:in `retrieve_collector_from_mimes' 
/usr/local/rvm/gems/[email protected]/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/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:447:in `_run__2723577406764024271__process_action__2755147847840742796__callbacks' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:17:in `process_action' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/rescue.rb:29:in `process_action' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `block in instrument' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `instrument' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:29:in `process_action' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/params_wrapper.rb:207:in `process_action' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/railties/controller_runtime.rb:18:in `process_action' 
/usr/local/rvm/gems/[email protected]/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/rub[email protected]/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/[email protected]/gems/newrelic_rpm-3.6.1.87/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:37:in `process_action' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:121:in `process' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/abstract_controller/rendering.rb:45:in `process' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal.rb:203:in `dispatch' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_controller/metal.rb:246:in `block in action' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `dispatch' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:36:in `call' 
/usr/local/rvm/gems/[email protected]/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call' 
/usr/local/rvm/gems/[email protected]/gems/journey-1.0.4/lib/journey/router.rb:56:in `each' 
/usr/local/rvm/gems/[email protected]/gems/journey-1.0.4/lib/journey/router.rb:56:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:600:in `call' 
/usr/local/rvm/gems/[email protected]/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:184:in `call!' 
/usr/local/rvm/gems/[email protected]/gems/omniauth-1.1.4/lib/omniauth/strategy.rb:164:in `call' 
/usr/local/rvm/gems/[email protected]/gems/newrelic_rpm-3.6.1.87/lib/new_relic/rack/error_collector.rb:12:in `call' 
/usr/local/rvm/gems/[email protected]/gems/newrelic_rpm-3.6.1.87/lib/new_relic/rack/agent_hooks.rb:18:in `call' 
/usr/local/rvm/gems/[email protected]/gems/newrelic_rpm-3.6.1.87/lib/new_relic/rack/browser_monitoring.rb:16:in `call' 
/usr/local/rvm/gems/[email protected]/gems/newrelic_rpm-3.6.1.87/lib/new_relic/rack/developer_mode.rb:28:in `call' 
/usr/local/rvm/gems/[email protected]/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call' 
/usr/local/rvm/gems/[email protected]/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch' 
/usr/local/rvm/gems/[email protected]/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' 
/usr/local/rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call' 
/usr/local/rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/head.rb:14:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/params_parser.rb:21:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/flash.rb:242:in `call' 
/usr/local/rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context' 
/usr/local/rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/cookies.rb:339:in `call' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:64:in `call' 
/usr/local/rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__2979100583981751168__call__3555748325778021510__callbacks' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/reloader.rb:65:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
/usr/local/rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app' 
/usr/local/rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call' 
/usr/local/rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call' 
/usr/local/rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call' 
/usr/local/rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
/usr/local/rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call' 
/usr/local/rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call' 
/usr/local/rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call' 
/usr/local/rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application.rb:223:in `call' 
/usr/local/rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call' 
/usr/local/rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/rack/log_tailer.rb:17:in `call' 
/usr/local/rvm/gems/[email protected]/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) 
+0

Điều đó dường như phù hợp với cách tôi đang sử dụng nó trong ứng dụng Rails 3 của mình - mặc dù tôi có cấu hình pusher trong bộ khởi tạo, thay vì mỗi tệp cấu hình/môi trường/* .bb. – pat

+0

cảm ơn pat - tôi đã thử đặt cấu hình trong bộ khởi tạo thay thế. Vẫn gặp lỗi tương tự. Thật kỳ lạ, bây giờ khi tôi sử dụng cú pháp kích hoạt cũ (Pusher [tên kênh] ...) Tôi cũng nhận được lỗi ngay bây giờ - tôi đang nắm bắt các manh mối ở đây. có thể có điều gì đó trong ứng dụng rộng hơn của tôi đang can thiệp bằng cách nào đó không? – christian

+0

Bạn đã gấp ba lần kiểm tra không chỉ rằng bạn có thông tin xác thực đúng, nhưng chúng đúng thứ tự (ví dụ: bạn không có bí mật được đặt thành khóa, v.v ...)? – pat

Trả lời

18

Nhờ hỗ trợ pusher, giải pháp là để thiết lập sau cùng với các thông tin khác của tôi:

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

... điều này là bắt buộc làm ap của tôi p là trên cụm Heroku EU mới và pusher-gem gọi cụm Hoa Kỳ, nơi app_key/auth_key của tôi không hợp lệ.

+6

Điều này sẽ được quảng cáo nhiều hơn trong tài liệu của họ. Làm thế nào chúng ta có thể tìm ra cách khác? Cám ơn vì đã chia sẻ! –

+0

Điều này chắc chắn phải rõ ràng hơn trong tài liệu của họ, hoặc hy vọng là không cần thiết chút nào. Tôi đã dành ba ngày với sự hỗ trợ của họ về điều này mà không có một giải pháp. Điều này chỉ có vẻ là một vấn đề trong môi trường phát triển, ứng dụng EU sản xuất của tôi làm việc mà không có nó. – DannyB

Các vấn đề liên quan