Thank you for you clear explanation.
Just a further help: how can I know the <gateway_ip> and the <gateway_port> values via scripting?
In Perspective there is not currently an avenue for directly obtaining the Gateway’s IP. Long-term, the IP and port will either be a Session property or will be accessible via system.util.getGatewayAddress() (which returns both in one String, but is currently limited to Vision Clients).
As a workaround, you can make a Session Custom property and specify the IP:port combo, although this will of course be brittle should you migrate, failover, load-balance, or use DNS.
We decided not to do this since the alternative method is already present and sufficient.