A client can choose to establish a session with the Volt. For clients that are simply consuming services, this isn’t always necessary. However if a client wishes to register a service with Volt for consumption by other clients, a session is required to ensure that the Volt can reliably determine when services are online and reachable.
A session can also be useful in consumer scenarios, because it makes things like reconnection and retries easier to manage. For example, if a client wishes to set up a reliable subscription to a Volt wire, the ‘connected’ event of a session can be used to signal the start of the subscription. If the session drops for whatever reason, a ‘disconnected’ event will be sent and the client library will automatically attempt periodic reconnection. Once the session is re-established, the ‘connect’ event is fired again and the client can restart the subscription.
Clients wishing to register a service(s) with the Volt must first establish a session. The Volt uses the session to control the lifetime of the services. If the session is dropped or explicitly closed, the Volt will move all the services registered by that client offline.
Both client libraries provide interfaces that make session creation and management relatively straight forward. See the How to establish a session section for more information.
As well as service registration management, sessions are used internally by the Volt to support the Relay concept. When a Volt establishes a Relay connection to another Volt, this is done using a session. See the InvokeRequest and InvokeResponse message types for more details.