Trying to subscribe to a platform Event channel from community keep failing for me.

All is working fine from internal User on a Lightning Record Page but for some reason cannot subscribe to the Channel from Community.

Am I missing something ? anything needed to add here to make it work on community?

Using LWC but no luck using Aura as well. Got the Platform Event Setup "TestEvent__e".

import { LightningElement,track, api} from 'lwc';
import { subscribe, onError } from 'lightning/empApi';

export default class TestComp extends LightningElement {
 channelName = '/event/TestEvent__e';
 subscription = {};

 handleSubscribe() {
    // Callback invoked whenever a new event message is received
    const messageCallback = (response) => {
    console.log('Platform Event received : ', JSON.stringify(response,null,' '));     

    // Invoke subscribe method of empApi. Pass reference to messageCallback
    subscribe(this.channelName, -1, messageCallback).then(response => {
        // Response contains the subscription information on successful subscribe call
        console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
        this.subscription = response; 
registerErrorListener() {
    // Invoke onError empApi method
    onError(error => {
        console.log('Received error from server: ', JSON.stringify(error));
        // Error contains the server-side error


<lightning-button variant="success" label="Subscribe" title="Subscribe"
    onclick={handleSubscribe} class="slds-m-left_x-small">


`<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <masterLabel>My Test Component</masterLabel>
    <description>Listen to EmpAPI</description>
  • in the Community's guest user Profile, did you enable read permissions for the Platform Event(s) in question? By default these are false.
    – cropredy
    Dec 16, 2019 at 23:30
  • yes have read and create permissions for the platform event object. any other permissions need to be enable for the community user?
    – sfdx bomb
    Dec 17, 2019 at 7:18
  • I just found this post which clarify I guess that (currently?) this is not support in community - salesforce.stackexchange.com/questions/243875/… - weird I imagined this is a good use case for platform Events.
    – sfdx bomb
    Dec 17, 2019 at 10:41

1 Answer 1


Unfortunately, you can't do it.

Because Community Users don't have access to Push Topics (idea), related question. And Platform Event, Data Change Event are built on Push Topics.

I have a similar use case where I need to use functionality in both Community and Internal, so I had to use different implementations based on the running environment.

UPDATE: actually you can answer

  • That’s really surprising - Unlike push topics - you can give Read and Create permissions on a Plaform Event object to a community profile - but after various attempts I had to go to a different route here. It seems like currently not supported.
    – sfdx bomb
    Dec 20, 2019 at 17:43
  • @ytiq how did you manage the "so I had to use different implementations based on the running environment"? What did you use here for Communities?
    – erikduvet
    Jan 22, 2020 at 23:14
  • yey, I wanted to fix this answer)) I found out that actually you can) You can download cometd and subscribe to Platform Events using it check accepted answer here. salesforce.stackexchange.com/questions/289584/…
    – ytiq
    Jan 23, 2020 at 8:04
  • What I meant is that I use events when component is used for communities and direct transactions when in Internal
    – ytiq
    Jan 23, 2020 at 8:05
  • Sorry for the wrong answer(
    – ytiq
    Jan 23, 2020 at 8:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .