【发布时间】:2014-10-28 17:26:13
【问题描述】:
我正在学习 Ruby on Rails 以在 Heroku 上使用 WebSockets 构建实时 Web 应用程序,但我无法弄清楚为什么在 Unicorn 服务器上运行时 WebSocket 连接失败。我将我的 Rails 应用程序配置为使用 Procfile 在本地和 Heroku 上运行 Unicorn...
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
...我在本地以$foreman start 开头。在客户端用javascript创建websocket连接时出现失败...
var dispatcher = new WebSocketRails('0.0.0.0:3000/websocket'); //I update the URL before pushing to Heroku
...在 Chrome Javascript 控制台中出现以下错误,'websocket connection to ws://0.0.0.0:3000/websocket' failed. Connection closed before receiving a handshake response.
...当我在 Heroku 上的 Unicorn 上运行它时,我在 Chrome Javascript 控制台中遇到了类似的错误,'websocket connection to ws://myapp.herokuapp.com/websocket' failed. Error during websocket handshake. Unexpected response code: 500.
Heroku 日志中的堆栈跟踪显示,RuntimeError (eventmachine not initialized: evma_install_oneshot_timer):
奇怪的是,当我使用命令$rails s 在瘦服务器上本地运行它时,它运行良好。
过去五个小时我一直在网上研究这个问题,但没有找到解决方案。任何解决此问题的想法,甚至是从我的工具中获取更多信息的想法,都将不胜感激!
【问题讨论】:
标签: javascript ruby-on-rails heroku websocket