与ip绑定后动作电缆无法正常工作 [英] Action Cable not working after binding with ip
问题描述
我已经在我的系统中实现了 rails-5 的动作电缆,它在 localhost
上工作正常,但是当我尝试与 ip 绑定时,它给出了以下错误消息.
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 连接到ws://192.168.1.46:3002/cable"失败:错误在 WebSocket 握手期间:意外响应代码:404
WebSocket connection to 'ws://192.168.1.46:3002/cable' failed: Error during WebSocket handshake: Unexpected response code: 404
并在终端日志中
无法升级到 WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION:升级,HTTP_UPGRADE: websocket)
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
我已经对我的 development.rb
进行了更改
I have made changes on my development.rb
as like
config.action_cable.url = "ws://192.168.1.46:3002/cable"
但没有成功.
请指导我哪里错了.
如果您需要更多信息,请告诉我,提前致谢.
tell me if you need extra information, Thanks in advance.
推荐答案
在config/environments/development.rb
文件中添加下面一行
config.action_cable.allowed_request_origins = [/http:\/\/*/, /https:\/\/*/]
希望对您有所帮助.
这篇关于与ip绑定后动作电缆无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!