kevinohara80 / nforce

nforce is a node.js salesforce REST API wrapper for force.com, database.com, and salesforce.com
MIT License
474 stars 167 forks source link

Streaming API connection time #16

Closed gazman101 closed 11 years ago

gazman101 commented 11 years ago

First of all thanks for the great work, really useful project!

Having an issue with the SalesForce Streaming API, it takes 2 minutes to connect to the pushtopic.

I'm assuming it's hitting a retry timeout is that the case?

Thanks

kevinohara80 commented 11 years ago

That's an odd one. I am assuming it's something on the SFDC end. Have you tried connecting to an entirely different Salesforce instance? Maybe your particular instance is having connection issues.

If I have some time tonight I'll try connecting to my dev org and see if I can see what you are seeing.

ChrisBland commented 11 years ago

I haven't seen this issue before. Have you seen it across multiple orgs? Can you post a gist of your code? Are you running in to these issues local and on a remote box?

gazman101 commented 11 years ago

Ok so I've tried it on a org and on new local machine, same issue.

The only thing I can see with my code is that I'm not doing anything with any responses going to the redirectUri, but as I'm getting an access token and eventually subscribing to the pushtopic I'm don't think that has anything to do with it?

Code looks like this..

var nforce = require('nforce');

var org = nforce.createConnection({ clientId: '_', clientSecret: '_', redirectUri: 'http://localhost:8080/oauth/_callback' });

var oauth;

org.authenticate({ username: '_', password: '_'}, function(err, resp){ if(!err){

    oauth = resp;

    console.log('Attempting to subscribe: ' + new Date())
    var str = org.stream('AllAccounts', oauth);

    str.on('connect', function(){
        console.log('connected to pushtopic: ' + new Date());
    });

    str.on('error', function(error) {
        console.log('error: ' + error);
    });

    str.on('data', function(data) {
        console.log(data);
    });

}else{
    console.log(err);
}

});

Log looks like this....

Attempting to subscribe: Sun May 05 2013 11:50:23 GMT+0100 (BST) connected to pushtopic: Sun May 05 2013 11:52:15 GMT+0100 (BST)

Thanks in advance

kevinohara80 commented 11 years ago

I have actually seen that before. If I remember correctly, the connect callback fires after you are actually connected and able to receive events. Have you tested invoking the pushtopic before you get that connect event? I think I was able to get the events prior to getting the connect callback.

kevinohara80 commented 11 years ago

Closing for now. If you have more data feel free to re-open.