Skip navigation.

CometD 2 & WebSocket

Enabling/Disabling WebSocket support in CometD 2

Since CometD 2.1.0, WebSocket support has been disabled by default, since the support in browsers is still too buggy.
The JavaScript WebSocket transport is there, but it's disabled.

However, the CometD demo has WebSocket support enabled, and you can have that too in your applications simply by executing this code in your JavaScript application:

// Using dojo style; use $.cometd for jQuery
var cometd = dojox.cometd;
cometd.websocketEnabled = true;

This code must be execute before the handshake to be effective.