我有一个带有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";
}在后端,我有以下代码用于向客户端发送通知
WebsocketRails[:callback_requests].trigger 'new', call_request在客户端,我使用以下命令获得了一个连接:
dispatcher = new WebSocketRails window.location.host + ':3001/websocket'
channel = dispatcher.subscribe 'callback_requests'但是客户端不会收到通知。
github - github.com/websocket-rails/websocket-rails/issues/211上的相关问题
发布于 2014-08-26 17:42:06
您的nginx配置正在将/websocket/下的请求与尾随的/进行匹配。这是/websocket/blah的目录组件。
如果你查看你的nginx访问日志文件,你会发现你对/websocket的请求被301重定向到了/websocket/。
删除尾随的/
location /websocket {
proxy_pass http://localhost:3001/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}https://stackoverflow.com/questions/23363874
复制相似问题