【发布时间】:2015-06-09 20:36:40
【问题描述】:
Websockets 可以比普通的 HTTP(s) 请求更快,并且浏览器通常可以打开更多的 websocket 连接。
我的浏览器通过 javascript 控制台告诉我,虽然我的闪亮应用程序正常工作并且 apache proxypass 代理正确,但 websockets 不工作:
WebSocket connection to 'wss://www.example.com/shiny/01_hello/__sockjs__/058/v193lng7/websocket' failed: WebSocket is closed before the connection is established.
我已经看到了可以将 Apache 配置为代理 websocket 的不同方式。如:
ProxyPass /shiny/ ws://127.0.0.1:3838/
ProxyPass /shiny/ wss://127.0.0.1:3838/
RedirectMatch ^/shiny$ /shiny/
和:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:3001/$1 [P,L]
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
我的问题是,这些中的任何一个都可以与闪亮一起使用吗?
【问题讨论】:
-
我有一个相关的问题。使用 apache 代理,我闪亮的应用程序被准系统断开,并且我在闪亮的服务器日志中看到“RobustSockJS 冲突”消息。为 ws: 添加 websocket proxypass 或/和 proxypassreverse 确实有所改善。
标签: r apache proxy websocket shiny