Hot answers tagged

9

The error you are reporting is related to the fact that the Salesforce Platform does not yet provide a WebSocket server for Platform Events. While waiting for this feature, you have to add this line just after your call to cometd.configure(...) : cometd.websocketEnabled = false; This will switch CometD to a long polling transport. You can check out a ...


6

This is a know issue documented in the Platform Event project Build an Instant Notification App: If you notice an "Exception during handling of messages Unrecognized advice action handshake" error in your developer console, please turn off notifications for your org: From Setup, enter Notifications in the Quick Find box, then select ...


5

I'm receiving this message as well. Not in the Trailhead but in my own code both within Visualforce page and withing a lightning component. I don't think you can catch this exception as it's caught by the cometd.js client lib. Note... before that happens.... in a connect listener I am seeing at 403::Unknown Client message.. then the cometd tries to ...


5

I'm the author of aiosfstream. Thanks for notifying me about this question! tl;dr You can use aiosfstream to subscribe and listen for platform events, but you can't use it for publishing. To publish platform events you have to use one of the documented methods. Since you're trying to publish events from a python application, publishing events with the ...


4

I don't know if this is the right answer but I'm gonna drop the possibility here... Locker Service defines a few trusted origin domains. Take a look at this commit: https://github.com/forcedotcom/aura/commit/495eaccdc3292a6cf2dcd2c2347c0329c06339e0#diff-7029ab74270f2b05e936f8a47738b1a7 In the code base as of Spring 18's release date, we see (https://github....


4

There are some Salesforce Docs on Subscribe to and Replay Events Using a Visualforce Page. They seem like a good place to start. Here I'll replicate that example, except from sfdx. sfdx force:project:create --projectname cometd cd cometd mkdir mdapipkg git clone https://github.com/developerforce/SalesforceDurableStreamingDemo.git mdapipkg Remove the ...


4

If you view the documentation for lightning:empApi, It only works in Lightning experience or Salesforce mobile. I try to view your component as VF page or just the App then it fails to load. then I embedded your component into a flexiPage and see it works just fine.


4

I ran a search using http://findsf.info/ and could only find references to Salesforce supporting ver 2.20 of CometD. By chance, I came across something else that may be of use to you. It's a reference to using NodeJS with the Streaming API that was linked to a Blog on how to use CometD and the Streaming API with Order Information Objects to create push ...


4

I found out that ConversationReload Event doesn't have access="global" and VF Page from where I was trying to access event was not part of the package.


4

This isn't a complete answer, because it doesn't solve your issue. But I wanted to explain what you're seeing with that error message. Even though getErrors returns an error, that "error" is technically a success, as you can see in the presence of an id, and the isSuccess flag being true. I ran into this issue through the REST/SOAP API when an external ...


4

Looks like you have used wrong variable name , happens when you copy paste the code from somewhere else , Here is the line that needs to be checked sessionAction.setCallback(this, function (a) { var state = response.getState();//response is not defined ... Lets change the above lines to this sessionAction.setCallback(this, function (response) { ...


3

You can't push a message to Salesforce event bus through CometD. From the doc: Streaming API supports the following CometD methods: connect The client connects to the server. disconnect The client disconnects from the server. handshake The client performs a handshake with the server and establishes a long polling connection. subscribe ...


3

As sbordet said in the comment above, there was a solution (or at least workaround) given in the question I linked to, that I somehow missed. Here is the workaround provided by Grekker in that thread: The cometd library on GitHub since version 3.1.2 added a line of code that Salesforce doesn't like, my guess is because it changes XHR and LockerService is ...


3

Forget it the HOST in the URL is wrong https://na73.salesforce.com should be used instead of https://na73.lightning.force.com/


3

As @sfdcfox mentioned in the comments, the new lightning:empApi component can be used to achieve multiple streaming connections in a single component or browser window. I got this working with multiple lightining:empApi tags in a single component, using unique aura:Ids to access their subscribe methods through the JS controller and helper. You can access ...


2

The Lightning Component framework uses Content Security Policy (CSP), which is a W3C standard, to control the source of content that can be loaded on a page. To use third-party APIs that make requests to an external (non-Salesforce) server, add the server as a CSP Trusted Site. When you define a CSP Trusted Site, the site’s URL is added to the ...


2

You could just add a bit of code: <aura:attribute name="streamingEnabled" type="Boolean" default="false" /> <aura:attribute name="streamingLoaded" type="Boolean" default="false" /> <aura:registerEvent name="onloaded" type="c:streamingEnabled" /> <aura:handler name="change" value="{!v.streamingEnabled}" action="{!c.handleEnable}" /> ...


2

This use case is addressed in the following Amazon AppFlow Trailhead module Basically you configure AppFlow to subscribe to Salesforce Platform Events and then you can continue your logic in AWS, for example process the event data with a Lamda function, send it to an S3 bucket, or other AWS handled logic


2

As you are using an anonymous function, it will not have access to the this of your component. A this inside that function will refer to the function itself. To overcome this, you have two options. 1 Use an arrow function cometdlib.subscribe('/event/MSG_Internal_COMM__e', (msg) => { this.invokeLWCApexMethod(); }); 2 Pass this as another variable i.e. ...


1

Does this help? source https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/using_streaming_api_stateless.htm “In API version 37.0 and later, Streaming API stores events for 24 hours, enabling you to replay past events. With durable streaming, messages aren’t lost when a client is disconnected or isn’t subscribed. When the ...


1

We can publish event to Salesforce EventBus from an external application by making use of API only. You can use any Salesforce API to create platform events, such as SOAP API, REST API, or Bulk API. To publish a platform event message using REST API, send a POST request to the following endpoint: /services/data/v49.0/sobjects/Event_Name__e/ For More Details:...


1

I am the CometD Project leader but I don't know the details of the SalesForce integration, so my answer may or may not apply. When a CometD client first connects to a CometD server, it sends a handshake request. The server replies with a handshake reply and sends back a normal HTTP cookie called BAYEUX_BROWSER. Every subsequent message sent by the client ...


1

Although not a direct solution, I have also had similar issues with the 403::Unknown Client error. What I noticed with the seemingly inconsistent subscriptions was that the error would only occur when the subscription tried to connect before the page was finished loading. I found that by stalling the subscription for a few seconds, the page loaded and the ...


1

The problem in helper method posted is that it uses the isEmpEnabled function incorrectly. The isEmpEnabled function returns a promise not a boolean. If this is fixed so that isEmpEnabled is called correctly then waiting for a successful response and subscribing USUALLY does not result in a 403 error, but it still happens occasionally on the first load of ...


1

If you can spend a full platform license for it, you can. On your community uses Apex callout to log in into SF using Oauth2 flow. Store username-password for callout in Apex/ custom setting. The Oauth2 flow will return session ID, use that session Id to register for streaming API. Make sure your Platform user who's creds you are using has no data access ...


1

In the case of server timeouts, the client connects again and starts over. Reference > https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/BayeauxProtocolAndCometD.htm


1

I assume you were setting up the connection cross domain. It appears the streaming API isn't supported. Since salesforce hasn't setup CORS, the Preflight request will fail and you'll see that cometd is defaulting back to the Callback Polling Transport, which is then rejected because the endpoint only allows POST. I've tried the exact same code in a VF page ...


1

You can't currently1. The Bayeux protocal via CometD is the only push technology currently supported by Salesforce for the Streaming API. From Bayeux Protocol, CometD, and Long Polling: Long polling, also called Comet programming, allows emulation of an information push from a server to a client. Similar to a normal poll, the client connects and requests ...


1

[Disclaimer, I'm the CometD lead, so I can answer about CometD - what SalesForce uses may be slightly different although for this particular question I think the answer below holds for SalesForce too] CometD is based on non-blocking I/O and therefore it does not need a dedicated thread per connection. This is true for both HTTP (long-polling) and WebSocket ...


1

Original Question: This doesn't answer the original question of what's the latest version of CometD that can be used with Streaming API (@crmprogdev answer of CometD version 2.2.0 is by all accounts correct). Edited Question: But the following is a work-around to use any version of jQuery while still using jQuery 1.5.1 for Streaming API: Instead of using ...


Only top voted, non community-wiki answers of a minimum length are eligible