We having difficulty reproducing issue with server mismatch error that we get in our web client after device is returning from the background. What is recommended recovery method? restart connection? store existing subscriptions create new client and try to resubscribe to the same subscription channels?
server mismatch Recovery
What client version are you using and what is the specific error you encountered?
It would also be helpful if you could enable the client logger and share the log with us.
Alessandro.Carioni lightstreamer-client-web -9.2.0
Error: Wrong session ID
ErrorCode: 21
we could not enable logger for all the clients it would be to much info. if it was easily reproducible i would be turning on for local development. But it is not. most of this errors are on ios-safari when user returns from background as far as we could understand
Do you have a load balancer using cookie affinity in front of a cluster of Lightstreamer servers?
If so, error 21 could indicate that when a client returns from the background and tries to recover the session, it reaches the wrong server, i.e., a server other than the one that created the original session.
To prevent this error, you should set the CookieHandlingRequired parameter to true and ensure that the load balancer is correctly configured to set and read affinity cookies upon the client's requests.
Alessandro.Carioni we are currently using ip affinity in HA proxy. but in any case in particular rare case this affinity is failed. What is prefered way to reconnect or establish new connection?
You can listen for the onServerError event and, if the error code is 21, connect again.
For example:
client.addListener({
onServerError(code, msg) {
// at this point the client is disconnected
if (code == 21) { // wrong session id
client.connect()
}
}
})