我用作后端框架Ruby on Rails 5,实际上是用于websocket连接的动作电缆和前端Android。我在https://github.com/rails/actioncable-examples中创建服务器,并使用库https://github.com/hosopy/actioncable-client-java创建客户端连接。当我连接到服务器时,它每次都失败,例外:
Started GET "/cable" for 192.168.0.106 at 2017-06-15 17:57:19 +0500
Cannot render console from 192.168.0.106! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Started GET "/cable/" [WebSocket] for 192.168.0.106 at 2017-06-15 17:57:19 +0500
Request origin not allowed:
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
Finished "/cable/" [WebSocket] for 192.168.0.106 at 2017-06-15 17:57:19 +0500
什么是问题,我做错了什么?
答案 0 :(得分:1)
我有同样的问题。看完一些我发现的东西后 "不允许请求来源:"由于动作电缆的伪造保护模块。 简单的解决方案是将此行添加到config / environments / yourEnvironment.rb:
config.action_cable.disable_request_forgery_protection = true
希望能帮助!!!