我有使用gem websocket-rails 0.7的Rails 3.2应用程序.
在开发机器上,一切正常
在生产环境中,我使用Nginx/1.6作为代理服务器,使用Unicorn作为http服务器.Thin用于独立模式(遵循https://github.com/websocket-rails/websocket-rails/wiki/Standalone-Server-Mode).
nginx配置:
location /websocket {
proxy_pass http://localhost:3001/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Run Code Online (Sandbox Code Playgroud)
在后端方面,我有以下代码用于向客户发送通知
WebsocketRails[:callback_requests].trigger 'new', call_request
Run Code Online (Sandbox Code Playgroud)
在客户端,我使用以下连接:
dispatcher = new WebSocketRails window.location.host + ':3001/websocket'
channel = dispatcher.subscribe 'callback_requests'
Run Code Online (Sandbox Code Playgroud)
但通知不会发给客户.
关于github的相关问题 - github.com/websocket-rails/websocket-rails/issues/211