add websocket docs

This commit is contained in:
Ben Irvin 2023-06-26 13:08:23 +02:00
parent 8627f96d89
commit e7e225ba5f
2 changed files with 30 additions and 4 deletions

View File

@ -14,8 +14,8 @@ Remote Strapi providers connect to an instance of Strapi over a network using a
Internally, the remote Strapi providers map websocket requests to a local Strapi provider of the instance it is running in.
## Websocket Server
In order to use remote transfer providers, the remote Strapi server must have a value for `transfer.token.salt` configured in `config/admin.js` and the remote transfer feature must not be disabled.
When the data transfer feature is enabled for a Strapi server (a transfer token salt has been set on the server and STRAPI_DISABLE_REMOTE_DATA_TRANSFER is not set to true), Strapi will create websocket servers available on the routes `/admin/transfer/runner/pull` and `/admin/transfer/runner/push`.
## Disabling Remote Transfers
Opening a websocket connection on those routes requires a valid transfer token as a bearer token in the Authorization header.
If desired, the remote transfer feature of a server can be completely disabled by setting the environment variable `STRAPI_DISABLE_REMOTE_DATA_TRANSFER` to true.

View File

@ -8,4 +8,30 @@ tags:
# Remote Provider Websocket
**TODO**
When the data transfer feature is enabled for a Strapi server (an `admin.transfer.token.salt` config value has been set and STRAPI_DISABLE_REMOTE_DATA_TRANSFER is not set to true), Strapi will create websocket servers available on the routes `/admin/transfer/runner/pull` and `/admin/transfer/runner/push`.
Opening a websocket connection on those routes requires a valid transfer token as a bearer token in the Authorization header.
Please see the `bootstrap()` method of the remote providers for an example of how to make the initial connection to the Strapi websocket.
## Websocket Messages
After connecting to the websocket.
### Initialization Messages
** TODO **
### Pull Messages
** TODO **
### Push Messages
** TODO **
See `packages/core/data-transfer/dist/strapi/remote/handlers/push.d.ts` and `packages/core/data-transfer/dist/strapi/remote/handlers/push.d.ts`
## Message Timeouts and Retries
Because the transfer uses on a message->response protocol, if the websocket server is unable to send a reply, for example due to network instability, the connection would halt. For this reason, each provider's options includes `retryMessageOptions` which attempt to resend a message after a given timeout is reached and a max retry option to give up after a given number of failed retry attempts.