12

I have implemented action cable of rails-5 in my system and it's work fine on localhost, but when i tried to bind with ip it's give below error message.

WebSocket connection to 'ws://192.168.1.46:3002/cable' failed: Error during WebSocket handshake: Unexpected response code: 404

and in terminal log

Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)

I have made changes on my development.rb as like

config.action_cable.url = "ws://192.168.1.46:3002/cable"

but not succeed.

please guide me where i am wrong.

tell me if you need extra information, Thanks in advance.

0

1 Answer 1

25

Add below line to config/environments/development.rb file

config.action_cable.allowed_request_origins = [/http:\/\/*/, /https:\/\/*/]

Hope this will help you.

1
  • 8
    Even better, only whitelist the domains that you really want to allow. For example: config.action_cable.allowed_request_origins = [/http:\/\/www\.mydomain\.com/, /https:\/\/www\.mydomain\.com/] Nov 29, 2016 at 8:51

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.