【发布时间】:2016-01-23 20:12:09
【问题描述】:
我在Debian v8.2 上运行rabbitmq-server v3.3.5-1.1。根据docs 中的建议,我已启用rabbitmq_web_stomp 和rabbitmq_web_stomp_examples:
rabbitmq-plugins enable rabbitmq_web_stomp
rabbitmq-plugins enable rabbitmq_web_stomp_examples
http://127.0.0.1:15670 公开的所有示例都按预期工作,但它们都使用 SockJS 而不是本机浏览器的 WebSocket:
// Stomp.js boilerplate
var ws = new SockJS('http://' + window.location.hostname + ':15674/stomp');
var client = Stomp.over(ws);
我想坚持使用WebSocket,所以我尝试了文档中的建议:
var ws = new WebSocket('ws://127.0.0.1:15674/ws');
这会在我脸上抛出一个错误:
WebSocket connection to 'ws://127.0.0.1:15674/ws' failed: Error during WebSocket handshake: Unexpected response code: 404
netcat 的进一步测试确认404:
# netcat -nv 127.0.0.1 15674
127.0.0.1 15674 open
GET /ws HTTP/1.1
Host: 127.0.0.1
HTTP/1.1 404 Not Found
Connection: close
Content-Length: 0
Date: Sat, 23 Jan 2016 20:15:13 GMT
Server: Cowboy
显然cowboy 没有暴露/ws 路径,所以我想知道:
- 在这种情况下是否可以重新配置
cowboy?如何?这值得么? - 我可以使用
nginx代替cowboy(首选选项)吗?如何? - 我还有哪些其他选择?
编辑
RabbitMQ docs 具有误导性。正确的 WebSocket URI:
http://127.0.0.1:15674/stomp/websocket
【问题讨论】:
标签: nginx websocket rabbitmq cowboy