function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
stripathystripathy 

Invalid Session ID on trying simultaneous logins

Hi,

 

I am facing one issue where in if I try to create users using .NET and salesforce APIs, and if multiple persons use the same program it gives them a session invalid.

 

Do I need to use loginAsync instead of login?

 

Any ideas or sample code?

 

Thanks,

Santosh

SuperfellSuperfell

Without seeing any code, its impossible to say. Some things would be to make sure you're using an instance of the SforceService object for each thread/request, and not a shared/global single instance (as its not thread safe).

AlwaysConfusedAlwaysConfused

I've had this problem.

 

If I create a small app that does something like say query the API for a list of contacts then build and run 2 copies of it I get 1 copy working fine and the second seems to develop this invalid session ID error.

 

I got round it by catching the exception checking for this particular error then simply re-logging in with the failing app.

 

For some reason it seems to do it intermittently usually when 2 sessions are started in quick succession, it's almost like it returns 1 valid session ID and 1 invalid session ID but further examination reveals it's more likely a DDOS / other API protection mechanism where the API seems to think that 2 login requests in quick succession are actually 1.

 

Hope this helps :)