function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fakeha QuaziFakeha Quazi 

Not able to subscribe to Platform events using cometD in visualforce or force.com site

I am trying to subscribe to a Platform event in force.com site page in visualforce page. I am using cometD to subscribe.Using below code. It works internally in org. But when using the page on site page session id is null, so, it is not working. Is there any way to subscribe to platform event and access it on site page? 
cometd.websocketEnabled = false;
                      var auth = 'OAuth ' + '{!$Api.Session_ID}';
                      var cometdURL = window.location.protocol+'//'+window.location.hostname+ (null != window.location.port ? (':'+window.location.port) : '') +'/cometd/48.0/';
                      
                      cometd.configure({
                          url: cometdURL,
                          requestHeaders: { Authorization: auth}
                      });

 
SwethaSwetha (Salesforce Developers) 
HI Fakeha,
Are you viewing the site as a guest user? If so, you need to have full platform license for it.

See https://salesforce.stackexchange.com/questions/219946/platform-event-for-guest-community-user 

If this information helps, please mark the answer as best. Thank you