I have a problem connecting to web juice. An error has occurred:
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket) User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT ? [["LIMIT", 1]] An unauthorized connection attempt was rejected Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket) Finished "/cable/" [WebSocket] for 127.0.0.1 at 2016-09-11 18:57:49 +0200 Finished "/cable/" [WebSocket] for 127.0.0.1 at 2016-09-11 18:57:49 +0200
connection.rb
module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified_user logger.add_tags 'ActionCable', "User #{current_user.id}" end protected def find_verified_user if verified_user = User.find_by(id: cookies.signed[:user_id]) verified_user else reject_unauthorized_connection end end end end
I found some solution that should use config.allowed_request_origins , but it does not solve my problem. I tried with session_helper by adding this method:
def set_cookie(user) the_username = user.username.to_s cookies.permanent.signed[:username] = the_username end
Nothing repairs my problem.
Update: I saw that the problem is that cookie.signed [: user_id] is zero. Do you have any suggestions that might be causing this? I use the standard URL and port for tests (localhost: 3000).
source share