Stwissel / node-red-contrib-salesforce

A set of Node-RED nodes to interact with Salesforce and Force.com
MIT License
10 stars 17 forks source link

is it possible to reuse login token? #24

Open javaknight opened 6 years ago

javaknight commented 6 years ago

Here's the problem I'm having . SalesForce limits logins to 3600 per hour. It appears that using this node, each access to SalesForce incurs its own login, and counts against my login limit. When the 3600 limit is reached, the token is banned for 1 hour, and further accesses on that token fail at authentication.

Is it possible for this node to keep a login active once a node gets it, and share the login session with other nodes using the same credentials?

Stwissel commented 6 years ago

The login credentials are stored in the configuration node. You can use that configuration node for all types of nodes. So the foundation is there. What you are asking is: alter the code to preserve the authenticated session until timeout instead of creating a new session on each operation? Did you check the code where such a change would fit?

javaknight commented 6 years ago

Yes. I did try altering the code on my own. My change worked for 400 operations. I threw 4000 operations at the flow and node-red ran out of memory and crashed. So maybe my change wasn't ideal? I moved authentication up to where the node first grabs credentials from the configuration node. I also set autoRefresh to true.

On Fri, May 11, 2018, 7:56 PM Stephan H. Wissel notifications@github.com wrote:

The login credentials are stored in the configuration node. You can use that configuration node for all types of nodes. So the foundation is there. What you are asking is: alter the code to preserve the authenticated session until timeout instead of creating a new session on each operation? Did you check the code where such a change would fit?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Stwissel/node-red-contrib-salesforce/issues/24#issuecomment-388513125, or mute the thread https://github.com/notifications/unsubscribe-auth/AESNGyrSzZ4yviIi1YyCU84ERhrKdsF3ks5txiVIgaJpZM4T74LA .

Stwissel commented 6 years ago

@javaknight Would you mind sharing your code. I might be able to spot the memory leak

javaknight commented 6 years ago

somewhere along the line I missed github syntax, or didnt do the right commands. I used git clone, then set the master to the repo I set up. I guess I missed something, since it doesnt recognize it as a fork or relative of the project.

https://github.com/javaknight/sfnodered

1) first, i dont know why it thinks I changed package.json, as I didn't

2) the changes to soql.js, I did make those changes.

I'm also aware that the changes do mess up the possibility of a message object being passed into the node to configure it. But at the time, my biggest concern was to produce a proof of concept to see if I could stop the node from using 1 login per query.

Stwissel commented 6 years ago

The connection reuse needs to happen in the nforce wrapper - I'll add it there

dwindibank commented 6 years ago

FYI ... @tiyolab created a fork that handles re-using the token, but moving the creation of the connection to the connection node ... node-red-contrib-salesforce-stratus360

It looks like a pretty good way to handle it and might be easier then moving the connection caching into the nforce object. One issue is that @ityolab's fork is based off the the original jeffdonthemic's version.

Stwissel commented 6 years ago

I’ll have a look. I forked the nforce Object to nforce8 with less and more current dependencies. New release is planned for Dreamforce. Just crazy day job slows me down

On Tue, 14 Aug 2018 at 03:33, Dustin Windibank notifications@github.com wrote:

FYI ... @tiyolab https://github.com/tiyolab created a fork that handles re-using the token, but moving the creation of the connection to the connection node ... node-red-contrib-salesforce-stratus360 https://github.com/tiyolab/node-red-contrib-salesforce-stratus360/commit/dc021eb348201348e3e46a916f002fe4446a2508

It looks like a pretty good way to handle it and might be easier then moving the connection caching into the nforce object. One issue is that @ityolab's fork is based off the the original jeffdonthemic's version.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Stwissel/node-red-contrib-salesforce/issues/24#issuecomment-412636962, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhHVTbK1KLG2ZCyD0yLZhVSyarHx_Atks5uQdSGgaJpZM4T74LA .

-- Mobile message, pegged on glass.

Best regards Stephan H. Wissel http://www.wissel.net/

Stwissel commented 5 years ago

We are working on adding more auth options. Jwt and reflected auth is big on the list. Fixing reuse too

dwindibank commented 5 years ago

Awesome!

By reflected auth, do you mean passing a SessionId?