【发布时间】:2017-08-11 08:46:07
【问题描述】:
我有一个使用 CometD 3.1.2 的 Angular 应用程序并尝试使用 CometD 2.9.1 连接到服务器。
用于连接的代码如下:
let cometInstance = new cometdlib.CometD();
// Configure the CometD object.
cometInstance.configure({
url: 'http://host/cometd',
logLevel: 'debug',
requestHeaders: { ... }
});
// Handshake with the server.
cometInstance.handshake(function(h) {
if (h.successful) {
console.log('Notification handshake done');
cometInstance.subscribe('/topic', function(m) { ... }
} else {
console.log('Notification handshake fail');
}
});
第二次握手成功,客户端上的 CometD 日志包含大量从服务器接收到的重试指示,如下所示:
"New advice"
{
[functions]: ,
__proto__: { },
interval: 2000,
maxInterval: 0,
reconnect: "retry",
timeout: 30000
}
CometD 客户端发出的请求如下:
请求 GET /cometd/connect?jsonp=_cometd_jsonp_51&message=[{"id":"54","channel":"/meta/connect","connectionType":"callback-polling","clientId":"5pz4aijzuiiawglp5nccxdksj"}] HTTP/1.1
收到的答案是
_cometd_jsonp_51([{"id":"54","successful":true,"advice":{"interval":2000,"reconnect":"retry","timeout":30000},"channel" :"/meta/connect"}])
但是,即使它们在服务器日志中显示为已发送,我也没有从服务器收到有关订阅主题的任何消息。我担心这种无法接收消息是由于客户端和服务器之间缺乏兼容性造成的。
有没有人尝试将 CometD 3.1.2 客户端连接到 2.9.1 服务器? CometD 是否有任何兼容性矩阵? CometD 文档没有包含太多关于客户端和服务器之间的兼容性的内容。
谢谢
【问题讨论】: