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
David Lee 8David Lee 8 

Connection to Partner API is unsuccessful: "INVALID_SESSION_ID"

Hello Folks,
I suddenly have an issue connecting to the Partner API as any attempt to reconnect results in a INVALID_SESSION_ID.
The sandbox has no issues making the connection and the production environment had no issues as well until today when the logs started indicating no new sessions were being establised. It showed the following error message:

"INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key: XXX"

No changes were made to the password nor the token.
The partner api connection url in sandbox is:

As shown below in the Java excerpt below, any unsuccessful attempts in connecting to the Partner API should result in creating a new session but is faliing to do so.
try {
			// Check if session is still valid
			return true;
		catch (UnexpectedErrorFault uef) {
			if (uef.getExceptionCode() == ExceptionCode.INVALID_SESSION_ID) {"Session was invalid. Attempting to start new session");
				try {
					this.connection = new PartnerConnection(this.getConfig());
					return true;
				catch (ApiFault af) {
					logger.error("Salesforce ApiFault Exception occurred");
					return false;

Could any one suggest or advise what could have possibly gone wrong?

Thanks in advance for your help!
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@ David Lee 8:

  Have you checked the number of active sessions for the username and password that were being used to connect? and also the total API calls used so far today?


David Lee 8David Lee 8
Thanks Balaji. I've checked the number of active sessions and there was only 1 active API session.
Also, the total API calls on a daily basis was 700 at max, out of the 15,000 limit so I'm suspecting we are well within the bounds.
Would you have any other suggestions?
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@David Lee,

 If you still encounter the same issue, can you try checking out the security token? if have changed by any chance? other than the instance of the org, no. of active sessions, security token change i can not guess any other reason why a working code would fail!?