Action Cable not working after binding with ip

和自甴很熟 提交于 2019-12-05 20:24:03

问题


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.


回答1:


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

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

Hope this will help you.



来源:https://stackoverflow.com/questions/38719359/action-cable-not-working-after-binding-with-ip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!