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
TRUE DIALOGTRUE DIALOG 

Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session hash: : This error usually occurs after a session expires or a user logs out.

 using (var auth = new Enterprise.SoapClient())
            {
                var userId = "XXX";

                var password = "XXX";
                 
                Enterprise.LoginResult result = auth.login(null, new Enterprise.CallOptions(), userId , password);
   
                var client = new SendSMSContactControllerPortTypeClient();

                client.SendSMSContact(new SessionHeader() { sessionId = result.sessionId }, new CallOptions(), null, null,
                   model.PhoneNumber, model.Message); 
            }


My question is for some reason the "SendSMSContact" returns following error, any sugessions or ideas are greatly appreciated.

Exception Details:

Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session hash: This error usually occurs after a session expires or a user logs out.
jigarshahjigarshah
These are the below reasons that I can think of which could cause this issue.
  • This error occurs when a subsequent SOAP Service Request is trying to perform any operation however, the session connection may have timed out due to elasped time between 2 subsequent requests. Hence, the Session Id which is included in the SOAP Header of your service request is not valid anymore. You can try setting the Session Timeout value to its maximum which is 120 seconds.
  • Additionally, the Session Id value included in the header is incorrect and hence you could do the following.
    • If you get this error, use appropriate retry mechanism to login again with the given credetnials which will create a new connection and permit you to perform the transaction.
Daniel BoiceDaniel Boice
I was getting this error in vscode when I tried to deploy my code, despite being logged in to the org and authorizing it several times.in VS CODE.  I was also logged into another org with a different username in an open browser window.  I logged out of the other session and closed the browser and relogged in in VS Code and the problem went away.  Maybe you cannot be logged into two different orgs on the same machine with different logins?  
Daniel BoiceDaniel Boice
I think I figured out what it was.  It was my VPN changing IP addresses.  I unchecked the Lock Sessions to the domain in which they were first used.  That seems to fix it for me.
image of session settings