• Zhicheng Xie
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi Salesforce community, I have the exact same questions as this old post:
https://developer.salesforce.com/forums/?id=9060G000000UVwHQAW

, and there is no official document about which API shall return SwitchServer response.

Want to check if Denys's answer is still correct?

Also I am curious if handling SwitchServer should be used together with ReconnectSession API? For ReconnectSession request, while a session is reconnected, the new session shall be connected to a new available server, so I think we should then use the new serverUrl for future requests right? how do we know the new serverUrl? the document doesn't mention it, so I guess it should come from SwitchServer  response by Availability request. Or, maybe we should continue to use the old serverUrl for future requests after a session is reconnected and salesforce side has some magic to redirect our request to a new server? 

If possible, please help provide some real use case of ReconnectSession request

same question in this port: https://developer.salesforce.com/forums/?id=9060G000000UVwHQAW#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=9062I000000R2QlQAK
Is there any example using ReconnectSession API? 
https://developer.salesforce.com/docs/atlas.en-us.live_agent_rest.meta/live_agent_rest/live_agent_rest_ReconnectSession.htm?q=reconnect

After the session is re-connected to a new server, how do we know the new server url? Or should I continue use the old server url(which makes no sense, as the old server should be unavailable now right?)


Because I am not able to make my sandbox server unavailable to mimic the 503 response, if I reconnect the active session, it seems to be reconnected to the original session, but not a new session on a new server:
 
  1. Fetch token, start chat, send message, get message
  2.  Reconnect session
curl --location --request GET 'https://c.la2-c1cs-ia5.salesforceliveagent.com/chat/rest/System/ReconnectSession?ReconnectSession.offset=96253666' \

--header 'X-LIVEAGENT-API-VERSION: 56' \

--header 'X-LIVEAGENT-AFFINITY: null' \

--header 'X-LIVEAGENT-SESSION-KEY: fa5d6147-88d6-4df6-8d97-3732775fdb65!1666822921803!rStYpYGnjO8vL5ZJdLaazwyifDE=' \

--header 'Cookie: X-Salesforce-CHAT=!dpwh9HG0MnJLq0p202VUGLOPABOB/Aa308j9VU9B4f7Cm+DdLBtu1XVQMZC+jcCyEw6xpWlx9WeTMUY='

{

   "messages": [

       {

           "type": "ReconnectSession",

           "message": {

               "resetSequence": true,

               "affinityToken": "b8f32388"

           }

       }

   ]

}

3. Continue send message, get message, with the new affinityToken value, but with the original session in the original server:

curl --location --request POST 'https://c.la2-c1cs-ia5.salesforceliveagent.com/chat/rest/Chasitor/ChatMessage' \

--header 'X-LIVEAGENT-API-VERSION: 56' \

--header 'X-LIVEAGENT-SESSION-KEY: 43c22996-5bdd-4d4d-89ef-fae39efc0335!1666823437073!FKJLWwUCCFBaZ+KQ4Qct2Joun48=' \

--header 'X-LIVEAGENT-AFFINITY: b8f32388' \

--header 'Content-Type: application/json' \

--header 'Cookie: X-Salesforce-CHAT=!dpwh9HG0MnJLq0p202VUGLOPABOB/Aa308j9VU9B4f7Cm+DdLBtu1XVQMZC+jcCyEw6xpWlx9WeTMUY=' \

--data-raw '{

   "text" : "Hi, I need help with my TV settings. I'\''m reconnected"

}

'


I believe the way I am using ReconnectSession API is not correct right? According to the document, when a session is re-connected, it should be connected to a new session on a new server. But how do I know the new server url?








 
We need ways to implement and test the code to handle the SwitchServer response in the Live Agent Rest API. The main questions we have are:
  • Which requests can throw this error? ChasitorInit is one, I suppose, but are there any others?
  • What is the error code returned along with it?
  • Is there any test endpoint we can use to simulate the response? I already tried to switch sandbox and production org ids and endpoints, but only got "503 - Service Unavailable".
  • How the mobile SDK handles it? I searched the github repo and found a reference in Feb 2017 release, but there was nothing about how it was handled.