Initiate a Websocket connection to the Avail LC API
You can use this method to actually connect to Avail Light Client web socket. Multiple connections are currently allowed.
To connect to the Avail LC websocket API, you need:
- Access to a running Light Client.
- A subscription ID generated using the
v2/subscriptions
method. - to run this wscat command in the terminal:
wscat -c ws://127.0.0.1:7000/v2/ws/{subscription-id}
Your terminal should look something like this:
Please note that you will regularly receive information related to the topics you chose to subscribe to
for as long as the ws
connection persists, even if you don't actually send any messages.
Every request should contain unique request_id field, used to correlate request with response.
Subscription IDs vs Request IDs
Each time you use the v2/subscriptions
method, you will receive a unique subscription_id.
This ID is used to connect to the websocket server.
Each of these IDs will be of the UUID4 format (opens in a new tab).
Coming to requests, every request you make to the websocket server should contain a request_id field, which will need to be a UUID4 value. You can choose to use a single, random UUID4 value to send all your requests, or you can use a unique UUID4 value for each request you send. The choice is yours.
Using a sngle UUID4 value is simple, but using a unique UUID4 value for each request can help you correlate each response with a unique request.
The Avail LC API was designed with dev experience in mind, and this way you can choose the way that suits you best.