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

Handling session timeout

Dear Sir,


Thanks in advance, we are using And we are doing some projects around Your applications hold major core part of our developments.  


We need to know best way for handling the problem occurs because of session timeout.

Currently we are using API version 7.0.   And in this version if any session timeout exception occurs it is throwing the following message-





 faultString: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader





ESSION_ID</ns1:exceptionCode><ns1:exceptionMessage>Invalid Session ID found in SessionHeader</ns1:exceptionMessage>


Now on the basis exception code (INVALID_SESSION_ID) of the above message we are going ahead in our projects. Just we want to make sure that in future whether you will make any changes in this code. If so how we will able know about this change.


It will be great if you will help us to solve this issue.







This value will not change.



 we are also facing this problem of invalid session id. when we try to create any lead or account it throws the exception: invalid_session_id found in the sessionheader .

 do u have any solution on this problem , if u have plz le me know



It was not clear in your post that in what scenario you are facing this problem.

I will try my best to help u in this regard.

The only way you can do is that you will have to implement the retry logic in the catch block. Like when a exception occurs in any of the function which makes AppExchange API calls you will have to get the Exception code from the instance of the Exception and if the code is equal to “INVALID_SESSION_ID” then you will have to make login call again and you will have to call this method again in which you have got exception.

 But this solution is not preferable in the case of creation of records in AppExchange because you might create duplicate records by calling the same method again. This would work fine in the case of updation, deletion etc.


Hope you must be aware of setting session time in AppExchange through UI. You can set a bit greater value for session time out there,  this way you can avoid this problem up to good extent.