From 3bb8e249d2fd84e56f27b1ea4af0252d45f7aa79 Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Wed, 22 Jan 2025 12:45:06 +0200 Subject: [PATCH] improve some explanations --- .../list-subscriptions-message.md | 6 +++--- .../websockets-stream-api/overview.md | 13 +++++++------ .../websockets-stream-api/subscribe-message.md | 16 +++++++--------- .../websockets-stream-api/unsubscribe-message.md | 8 ++++---- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/list-subscriptions-message.md b/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/list-subscriptions-message.md index bb494790a6..16596bbfe1 100644 --- a/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/list-subscriptions-message.md +++ b/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/list-subscriptions-message.md @@ -43,6 +43,6 @@ If there are no active subscriptions, `subscriptions` array will be empty. ### Request fields -| Name | Type | Mandatory | Description | -|----------|--------|-----------|-----------------------------------------------------------------------------------------| -| `action` | STRING | YES | Action to perform. Must be `list_subscriptions` to initiate a list subscription request | +| Name | Type | Required | Description | +|----------|--------|----------|-----------------------------------------------------------------------------------------| +| `action` | STRING | YES | Action to perform. Must be `list_subscriptions` to initiate a list subscription request | diff --git a/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/overview.md b/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/overview.md index fa45184ecc..6e964c2373 100644 --- a/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/overview.md +++ b/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/overview.md @@ -16,11 +16,11 @@ data. - **Endpoint**: The WebSocket server is available at: ``` - wss://api.flow.com/ws + wss://rest-mainnet.onflow.org/ws ``` - **Limits**: - - Each connection supports up to 10 concurrent subscriptions. Exceeding this limit will result in an error. - - Each subscription may provide up to 5 responses per second. + - Each connection supports up to 20 concurrent subscriptions. Exceeding this limit will result in an error. + - Each subscription may provide up to 20 responses per second. - After 1 minute of inactivity (no data is sent to/read from connection) connection is closed. - **Supported Topics**: - `blocks` @@ -38,7 +38,7 @@ data. Use any WebSocket client library to connect to the endpoint. Below is an example using JavaScript: ```javascript -const ws = new WebSocket('wss://api.flow.com/ws'); +const ws = new WebSocket('wss://rest-mainnet.onflow.org/ws'); ws.onopen = () => { console.log('Connected to WebSocket server'); @@ -184,7 +184,8 @@ If a request is invalid or cannot be processed, the server responds with an erro ### Asynchronous environments -If you're working in an asynchronous environment, our Stream API ensures **in-order message delivery**. +If you're working in an asynchronous environment, the Streaming API ensures **first-in first-out** message processing, +so responses will be returned in the same order the requests were received over the connection. You can leverage this feature to simplify your code and maintain consistency. -Additionally, you can use the `subscription_id` as a message identifier to manage subscriptions effectively. +Additionally, you can specify your own `subscription_id` in the subscribe request to easily identify the correct response. diff --git a/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/subscribe-message.md b/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/subscribe-message.md index a5499095d4..5b7756e16f 100644 --- a/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/subscribe-message.md +++ b/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/subscribe-message.md @@ -62,21 +62,19 @@ Subscribe requests must be sent as JSON in text frames, one request per frame. "subscription_id": "some-id-1", "error": { "code": 500, - "message": "access node is not responsible" + "message": "internal error" } } ``` ### Request fields: -| Name | Type | Mandatory | Description | -|-------------------|--------|-----------|-----------------------------------------------------------------------------------------------------------------------------------| -| `subscription_id` | STRING | NO | Optional unique identifier for the subscription. Max length of ID generated by client is 20. Server will generate UUID if omitted | -| `action` | STRING | YES | Action to perform. Must be `subscribe` to initiate a subscription | -| `topic` | STRING | YES | The topic to subscribe to, such as `blocks`, `block_digests`, etc. | -| `arguments` | STRING | NO | Additional parameters for the subscription, such as `start_block_id`, `start_block_height` or other. | +| Name | Type | Required | Description | +|-------------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------| +| `subscription_id` | STRING | NO | Optional unique identifier for the subscription. Max length of ID generated by client is 20. Server will generate UUID if omitted | +| `action` | STRING | YES | Action to perform. Must be `subscribe` to initiate a subscription | +| `topic` | STRING | YES | The topic to subscribe to, such as `blocks`, `block_digests`, etc. | +| `arguments` | STRING | NO | Additional topic specific parameters for the subscription, such as `start_block_id`, `start_block_height` or other. | You can use `subscription_id` as a client-generated identifier to track responses asynchronously. If you don't provide `subscription_id`, the server will generate one and include it in the response. - -The order of params is not significant. diff --git a/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/unsubscribe-message.md b/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/unsubscribe-message.md index 9bc718881b..069e0b0e4a 100644 --- a/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/unsubscribe-message.md +++ b/docs/networks/node-ops/access-onchain-data/access-nodes/accessing-data/websockets-stream-api/unsubscribe-message.md @@ -39,7 +39,7 @@ Unsubscribe requests must be sent as JSON in text frames, one request per frame. ### Request fields -| Name | Type | Mandatory | Description | -|-------------------|--------|-----------|-----------------------------------------------------------------------| -| `subscription_id` | STRING | YES | Unique identifier of the subscription | -| `action` | STRING | YES | Action to perform. Must be `unsubscribe` to initiate a unsubscription | +| Name | Type | Required | Description | +|-------------------|--------|----------|-----------------------------------------------------------------------| +| `subscription_id` | STRING | YES | Unique identifier of the subscription | +| `action` | STRING | YES | Action to perform. Must be `unsubscribe` to initiate a unsubscription |