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
dave6dave6 

Enterprise SOAP results in INVALID_SESSION_ID

I use the enterprise WSDL in several Salesforce integration applications and in one of them I now get the following error:

 

[UnexpectedErrorFault [ApiFault exceptionCode='INVALID_SESSION_ID'
exceptionMessage='Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key: 00DE0000000ZQOG!AQkAQH_TDBC7pF0GHrjxGNih.n.G4ztF73JBrw.DEF23CoiUyomdQbsVb_ic69oR5JGppDliGL1uy6dfOSMrxBSVNJCcMWEd'
]

 

My usage pattern is to create an instance of the EnterpriseConnection passing in the ConnectorConfig with login info, make a few queries/updates, then call logout on the EnterpriseConnection  instance then it goes out of scope.  All apps do basically the same thing as far as connecting/logout just the work is different.  Only one app has this error (so far).  We use the same login for all apps.

 

What is causing this and how do I fix it?  

 

SuperfellSuperfell

Login can share sessions between multiple login calls (when it thinks its really the same client), if you call logout, then you can end up pulling the session out from under the other instances the session was shared with. Just remove the call to logout. Or give all your integrations different oauth ids.

dave6dave6

Thanks for the reply and suggestion.  I did go through all the integration apps and removed calling logout but is their a way to be more robust about this fix?  I have no way to guarentee there won't be some other integration that does call logout.  That's the problem with code that has static behavior/state it makes it really hard to write robust code because some other logic you may have no control over 'leaks' into your own.

 

What if I caught this specific error, is there a way that I can reset/restart the session ID programatically?  E.g. is there a way to force it to generate a new session ID?

SuperfellSuperfell

You can catch the error and login again. Alternatively you can do an oauth login and give each integration its own oauth consumer, and then they won't share sessions.