mircea
mircea

Reputation: 503

Is a CometD 3.1.2 client compatible with a 2.9.1 CometD server?

I have an Angular application which uses CometD 3.1.2 and tries to connect to a server using CometD 2.9.1.

The code used to connect is like:

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');
  }
}); 

Handshake succeeds at the second attempt and the CometD logs on client contain lots of retry indications received from server like below:

"New advice"
{
      [functions]: ,
      __proto__: { },
      interval: 2000,
      maxInterval: 0,
      reconnect: "retry",
      timeout: 30000    
}

Requests issued by the CometD client are like:

Request GET /cometd/connect?jsonp=_cometd_jsonp_51&message=[{"id":"54","channel":"/meta/connect","connectionType":"callback-polling","clientId":"5pz4aijzuiiawglp5nccxdksj"}] HTTP/1.1

and the received answers are

_cometd_jsonp_51([{"id":"54","successful":true,"advice":{"interval":2000,"reconnect":"retry","timeout":30000},"channel":"/meta/connect"}])

However, I am not getting any message from server on the subscribed topic even they appear in the server logs as being sent. I am concerned that this failure to receive messages is caused by the lack of compatibility between client and server.

Has anybody tried to connect a CometD 3.1.2 client to a 2.9.1 server? Is there any compatibility matrix for CometD? CometD docs do not contain too much about compatibility between client and server.

Thanks

Upvotes: 0

Views: 183

Answers (1)

sbordet
sbordet

Reputation: 18477

The handshake reply you show above clearly has a successful: true field, so the handshake does succeed.

The advice that you show above that contains reconnect: "retry" is part of the Bayeux protocol, and it means that the client should issue a message on the /meta/connect channel, which also indicates that the handshake was successful.

The Bayeux protocol between CometD 2.9.x and 3.x did not change, so I expect that your configuration will work (and in fact, what you reported above shows that handshakes are indeed successful).

However, I recommend to update the client and the server to the same version, especially across major release numbers.

Upvotes: 0

Related Questions