Open gorugontula opened 5 years ago
same issue for me as well.
It's possible that this is working now in streaming 2.0 https://github.com/kevinohara80/nforce/blob/streaming-2.0/lib/fdcstream.js
I'm hoping to have 2.0 out within a week.
Once I have a beta out, it would be great if you both would test it for me and report back?
Not 100% related but digging through here did allow me to make my pushtopic work in 1.12.2
Connecting in single mode as described in the doc I was getting this error
"400::The replayId for channel {/topic/mypushtopic} wasn't found using the " +
'provided replay ID map {{}}. Ensure that the channel name you provided in ' +
'the replay map is valid and matches the channel name used for subscribing.'
I replaced the fdcstream.js in the 1.12.2 release with the one from the streaming-2.0 branch and changed the way I subscribe to the pushtopic (passing in /topic/mypushtopic instead of just the topic name, found here https://github.com/kevinohara80/nforce/blob/streaming-2.0/examples/stream.js)
With that I'm able to connect succesfully for the moment. Looking forward to the full 2.0 release, especially the typescript part! Nice work @kevinohara80
This workaround worked for me, thanks @Alasano. thank you @kevinohara80 for providing this super simple node library.
I took the latest version of committed fdcstream.js and updated my local files and it looks like the replay functionality works fine now. Thanks @kevinohara80 for actively working on the library to keep it update. This has been very handy.
This workaround also works for me, thanks @Alasano ! I changed fdcstream.js from: https://github.com/kevinohara80/nforce/blob/streaming-2.0/lib/fdcstream.js and changed the way i subscribe platform event (from eventName__e to /event/eventName__e)
Hi, is there any chance that the streaming-2.0 branch will merge to master? Anything we can do to help get it there?
I'm new to salesforce devving, and would like to subscribe to platform events, but am not so excited about copying files around. More than happy to take a fork and give it a test.
Alternatively, are you able to publish your streaming-2.0 library to npm as a beta?
This workaround also works for me, thanks @Alasano ! & @karoldylewski Finally I ended up with below code and its working fine with typescript.
import * as nforce from 'nforce'
import * as config from 'config'
import oAuth from '../types/oAuth'
class SalesforcePlatformEvents {
private organization: any;
constructor() {
this.organization = nforce.createConnection({
clientId: config.get('app.nforceKeys.clientId'),
clientSecret: config.get('app.nforceKeys.clientSecret'),
redirectUri: config.get('app.nforceKeys.redirectUri'),
environment: config.get('app.nforceKeys.environment'),
apiVersion: 'v44.0',
})
}
public startEventListner() {
const self = this.organization
self.authenticate({
username: config.get('app.nforceCredentials.user'),
password: config.get('app.nforceCredentials.pass'),
},
function(err: any, oauth: oAuth) {
if (err) return console.log(err)
if (!err) console.log('*** Successfully connected to Salesforce ***')
const client = self.createStreamClient({oauth})
const sub = client.subscribe({topic: config.get('app.nforceTopic.topic')})
client.on('connect', function() {
console.log('*** Streaming client transport: UP ***')
})
client.on('disconnect', function(data: any) {
console.log('*** Streaming disconnect : ' + data.reason)
console.log('*** Disconnect data', data)
})
sub.on('connect', function() {
console.log('*** Connected to topic: ' + sub.getTopic())
})
sub.on('error', function(error: Error) {
console.log('*** Error: ' + error)
sub.cancel()
client.disconnect()
})
sub.on('data', function(data: any) {
console.log('Data: ', data)
console.log('Current replay id: ' + sub.getReplayId())
})
})
}
}
export default SalesforcePlatformEvents
I am trying to subscribe to a platform event in salesforce and it works fine - except ability to replay events -either from a specific replayId or from the earliest available (-2). Below is the code that I am using - which is taken from a sample code provided in a salesforce doc but is not working - any help would be greatly appreciated.
`org.authenticate({ username: USERNAME, password: PASSWORD,securityToken: SECURITY_TOKEN }, function(err, oauth) { if(err) return console.log("Error authenticating to Salesforce, " + err); var client = org.createStreamClient();
I have also tried using "replayId" and "replayFrom" instead of retry but still no good. I am running this code from AWS Lambda - Node JS .