我正在开发一个有趣的项目,它需要我学习消息队列和websockets。我试图通过websockets将浏览器连接到使用sockjs而不是纯websocket的rabbitmq实例。在兔子我已经激活了stomp和web_stomp插件(使用sockjs时需要web_stomp)。RabbitMQ STOMP连接
我遇到的问题是,虽然来自浏览器的呼叫似乎正常工作,因为通过webstomp/stomp连接与兔子进行非常简短的连接,但在2或3秒后,连接被兔子。
这由RabbitMQ的日志证实:
= INFO REPORT ==== 11-JUL-2016 :: 23:01:54 === 接受STOMP连接(192.168.1.10:49746 - > 192.168.1.100:55674)
= INFO REPORT ==== 2016年7月11日:: 23:02:02 === 正在关闭STOMP连接(192.168.1.10:49746 - > 192.168.1.100:55674)
这是通过webstomp插件连接到RabbitMQ的浏览器代码:
var url = "http://192.168.1.100:55674/stomp"; var ws = new SockJS(url); var client = Stomp.over(ws); var header = { login: 'test', passcode: 'test' }; client.connect(header, function(){ console.log('Hooray! Connected'); }, function(error){ console.log('Error connecting to WS via stomp:' + JSON.stringify(error)); } );
这里是兔子的配置: [ {rabbitmq_stomp, [{default_user, [{login, "test"}, {passcode, "test"} ] }, {tcp_listeners, [{"192.168.1.100", 55674}]}, {heartbeat, 0} ] } ].
我一直在兔年文档一百万次,但这种感觉就像简单的东西,我俯瞰。