Connect stream
A client can choose to establish what’s known as a connect stream 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 connect stream is required to ensure that the Volt can reliably determine when services are online and reachable.
A connect stream 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 connect stream can be used to signal the start of the subscription. If the connect stream drops for whatever reason, a ‘disconnected’ event will be sent and the client library will automatically attempt periodic reconnection. Once the connect stream is re-established, the ‘connect’ event is fired again and the client can restart the subscription.
Service registration
Clients wishing to register a service(s) with the Volt must first establish a connect stream. The Volt uses the connect stream to control the lifetime of the services. If the connect stream is dropped or explicitly closed, the Volt will move all the services registered by that client offline.
Both client libraries provide interfaces that make connect stream creation and management relatively straight forward. See the How to establish a connect stream section for more information.
Remote invocation
As well as service registration management, connect streams 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 connect stream. See the InvokeRequest and InvokeResponse message types for more details.
This concept could be extended to enable any client to support remote invocation of arbitrary functions, i.e. it is not restricted to Volt endpoints. For example, a web client could establish a connect stream using the Javascript Web API, and upon receipt of a ConnectResponse message with an InvokeRequest payload respond with an appropriate InvokeResponse.