I am trying to subscribe to platform events on VF page. But getting WebSocket connection error. Not sure what am I doing wrong.
<apex:includeScript value="{!URLFOR($Resource.cometd, '/newCometd/cometd.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.scripts, '/scripts/jquery.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.cometd, '/newCometd/json2.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.cometd, '/newCometd/jquery.cometd.js')}"/>
(function($){
$(document).ready(function() {
// Connect to the CometD endpoint
$.cometd.init({
url: window.location.protocol+'//'+window.location.hostname+'/cometd/44.0/',
requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'}
});
// Subscribe to a topic. JSON-encoded update will be returned
// in the callback
$.cometd.subscribe('/event/Upload_Notification__e', function(message) {
//callRefresh();
});
});
})(jQuery)
Thanks in advance