TheVishnuKumar / lwc-streaming-api

Lightning Web Component Streaming API
http://www.0to1code.com/
BSD 2-Clause "Simplified" License
29 stars 15 forks source link

Error Subscribing Platform Event in Salesforce Community Site(Experience Cloud) #4

Open Daniel-Deepak-Dev opened 3 years ago

Daniel-Deepak-Dev commented 3 years ago

Hi @TheVishnuKumar , I was trying to subscribe the platform event in aura component place in a Community Site. I am getting an unsupported error. Could you please give us any solution?

Same happened, even If I use LWC. The problem must be with the Community Site.

aura_proddebug.js:55762 WARNING: Unsupported long-polling,callback-polling method: toJSON. Returning undefined

Error Response is

{
  "error": {
    "id": "1",
    "successful": false,
    "channel": "/meta/handshake",
    "failure": {
      "reason": "Not Found",
      "httpCode": 404,
      "connectionType": "long-polling",
      "transport": {},
      "message": {
        "id": "1",
        "version": "1.0",
        "minimumVersion": "1.0",
        "channel": "/meta/handshake",
        "supportedConnectionTypes": ["long-polling", "callback-polling"],
        "advice": { "timeout": 60000, "interval": 0 }
      }
    }
  }
}
TheVishnuKumar commented 3 years ago

Does your community profile have access to Push Topic? Based on this thread, the Community can not have access to push topics. https://salesforce.stackexchange.com/questions/129164/getting-streaming-or-alternative-to-work-for-customer-community-user-profiles

ChiragDhangar07 commented 2 years ago

@TheVishnuKumar @Daniel-Deepak-Dev
Any solution ? how to subscribe platform event in lwc for community sites. I tried both emapi and cometD but success messages are coming but not subscribing the events

chasd00 commented 2 years ago

There's an issue with cometd that's included in this component. I'm not sure if a new version of salesforce surfaced the issue or not. Unzip the static resource and look in cometd.js at line 621 where it says

this._debug('Could not copy transport context into XHR', e);

The problem is the "this" keyword is clobbered by the function and so _debug is not defined. Just comment out the line leaving the catch block empty.

I submitted a pull request to cometd to fix it the right way https://github.com/cometd/cometd/pull/1178