我有以下代码:
function connect() {
var socket = new SockJS('/MyWebApp/wsdemo');
stompClient = Stomp.over(socket);
stompClient.connect({}, function(frame) {
setConnected(true);
stompClient.subscribe('/user/queue/greetings', function(greeting) {
displayQueueMessage(greeting);
});
});
}
从机器A(本地机器)它工作得很好,我在连接时收到以下控制台日志(在chrome中):
Opening Web Socket... stomp.js:130
Web Socket Opened... stomp.js:130
>>> CONNECT
accept-version:1.1,1.0
heart-beat:10000,10000
stomp.js:130
<<< PONG stomp.js:130
<<< CONNECTED
heart-beat:10000,10000
session:ID:Developer1-PC-56865-1406014918730-2:25
server:ActiveMQ/5.9.0
version:1.1
stomp.js:130
connected to server ActiveMQ/5.9.0 stomp.js:130
send PING every 10000ms stomp.js:130
check PONG every 10000ms stomp.js:130
Connected: CONNECTED
version:1.1
server:ActiveMQ/5.9.0
session:ID:Developer1-PC-56865-1406014918730-2:25
heart-beat:10000,10000
index:23
>>> SUBSCRIBE
id:sub-0
destination:/user/queue/greetings
从机器B(同一局域网上的机器)它无法正常工作:(我连接时会收到以下控制台日志(在chrome中):
Opening Web Socket... stomp.js:130
Web Socket Opened... stomp.js:130
>>> CONNECT
accept-version:1.1,1.0
heart-beat:10000,10000
任何想法可能在这里出错?
谢谢!
答案 0 :(得分:0)
我遇到了同样的问题,我开始在不同的机器上测试我的应用程序,有些工作,有些没有,尝试禁用防病毒软件或防火墙。如果连接,请尝试配置防火墙。