From 14a3fd1f4483a21bc4a1fdb1ce3c65b8fdb3015c Mon Sep 17 00:00:00 2001 From: Ginger Collison Date: Mon, 29 Mar 2021 16:42:40 +0000 Subject: [PATCH] GitBook: [master] 210 pages modified --- SUMMARY.md | 2 +- nats-server/configuration/README.md | 4 +-- nats-server/configuration/websocket/README.md | 11 +++++++ .../configuration/websocket/websocket_conf.md | 33 +++++++++---------- whats_new_22.md | 2 +- 5 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 nats-server/configuration/websocket/README.md diff --git a/SUMMARY.md b/SUMMARY.md index 78bdfc9..e2a2eda 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -102,7 +102,7 @@ * [Configuration](nats-server/configuration/mqtt/mqtt_config.md) * [System Events](nats-server/configuration/sys_accounts/README.md) * [System Events & Decentralized JWT Tutorial](nats-server/configuration/sys_accounts/sys_accounts.md) - * [WebSocket](nats-server/configuration/websocket.md) + * [WebSocket](nats-server/configuration/websocket/README.md) * [Configuration](nats-server/configuration/websocket/websocket_conf.md) * [Managing A NATS Server](nats-server/nats_admin/README.md) * [Upgrading a Cluster](nats-server/nats_admin/upgrading_cluster.md) diff --git a/nats-server/configuration/README.md b/nats-server/configuration/README.md index 59ee50e..bdb642d 100644 --- a/nats-server/configuration/README.md +++ b/nats-server/configuration/README.md @@ -117,8 +117,8 @@ authorization: { | [`cluster`](clustering/cluster_config.md) | Configuration map for [cluster](clustering/). | | | [`gateway`](gateways/gateway.md#gateway-configuration-block) | Configuration map for [gateway](gateways/). | | | [`leafnode`](leafnodes/leafnode_conf.md) | Configuration map for a [leafnode](leafnodes/). | | -| [`mqtt`](https://github.com/nats-io/nats.docs/tree/53202d44215a11c4c4ad7caea03a703d302bc954/nats-server/configuration/mqtt/mqtt_conf.md) | Configuration map for a [mqtt](mqtt/). | | -| [`websocket`](https://github.com/nats-io/nats.docs/tree/53202d44215a11c4c4ad7caea03a703d302bc954/nats-server/configuration/websocket/websocket_conf.md) | Configuration map for [websocket](websocket.md). | | +| [`mqtt`](https://github.com/nats-io/nats.docs/tree/53202d44215a11c4c4ad7caea03a703d302bc954/nats-server/configuration/mqtt/mqtt_conf.md) | Configuration map for [mqtt](mqtt/mqtt_config.md). | | +| [`websocket`](https://github.com/nats-io/nats.docs/tree/53202d44215a11c4c4ad7caea03a703d302bc954/nats-server/configuration/websocket/websocket_conf.md) | Configuration map for [websocket](websocket/websocket_conf.md). | | ### Connection Timeouts diff --git a/nats-server/configuration/websocket/README.md b/nats-server/configuration/websocket/README.md new file mode 100644 index 0000000..fed3ea4 --- /dev/null +++ b/nats-server/configuration/websocket/README.md @@ -0,0 +1,11 @@ +# WebSocket + +_Supported since NATS Server version 2.2_ + +WebSocket support can be enabled in the server and may be used alongside the traditional TCP socket connections. TLS, compression and Origin Header checking are supported. + +**Important** + +* NATS Supports only WebSocket data frames in Binary, not Text format \([https://tools.ietf.org/html/rfc6455\#section-5.6](https://tools.ietf.org/html/rfc6455#section-5.6)\). The server will always send in Binary and your clients MUST send in Binary too. +* For writers of client libraries: a WebSocket frame is not guaranteed to contain a full NATS protocol \(actually will generally not\). Any data from a frame must be going through a parser that can handle partial protocols. See the protocol description [here](../../../nats-protocol/nats-protocol/). + diff --git a/nats-server/configuration/websocket/websocket_conf.md b/nats-server/configuration/websocket/websocket_conf.md index 889fc00..ce1184a 100644 --- a/nats-server/configuration/websocket/websocket_conf.md +++ b/nats-server/configuration/websocket/websocket_conf.md @@ -1,9 +1,12 @@ +--- +description: WebSocket Configuration Example +--- + # Configuration -To enable websocket support in the server, add a `websocket` configuration -block in the server's configuration file like the following: +To enable WebSocket support in the server, add a `websocket` configuration block in the server's configuration file like the following: -``` +```text websocket { # Specify a host and port to listen for websocket connections # @@ -102,13 +105,13 @@ websocket { } ``` -## Authorization of Websocket Users +## Authorization of WebSocket Users A new field when configuring users allows you to restrict which type of connections are allowed for a specific user. Consider this configuration: -``` +```text authorization { users [ {user: foo password: foopwd, permission: {...}} @@ -117,12 +120,9 @@ authorization { } ``` -If a websocket client were to connect and use the username `foo` and password `foopwd`, it would be accepted. -Now suppose that you would want websocket client to only be accepted if it connected using the username `bar` -and password `barpwd`, then you would use the option `allowed_connection_types` to restrict which type -of connections can bind to this user. +If a WebSocket client were to connect and use the username `foo` and password `foopwd`, it would be accepted. Now suppose that you would want the WebSocket client to only be accepted if it connected using the username `bar` and password `barpwd`, then you would use the option `allowed_connection_types` to restrict which type of connections can bind to this user. -``` +```text authorization { users [ {user: foo password: foopwd, permission: {...}} @@ -131,11 +131,9 @@ authorization { } ``` -The option `allowed_connection_types` (also can be named `connection_types` or `clients`) as you can see -is a list, and you can allow several type of clients. Suppose you want the user `bar` to accept both -standard NATS clients and websocket clients, you would configure the user like this: +The option `allowed_connection_types` \(also can be named `connection_types` or `clients`\) as you can see is a list, and you can allow several types of clients. Suppose you want the user `bar` to accept both standard NATS clients and WebSocket clients, you would configure the user like this: -``` +```text authorization { users [ {user: foo password: foopwd, permission: {...}} @@ -144,9 +142,10 @@ authorization { } ``` -The absence of `allowed_connection_types` means that all type of connections are allowed (the default behavior). +The absence of `allowed_connection_types` means that all types of connections are allowed \(the default behavior\). The possible values are currently: + * `STANDARD` * `WEBSOCKET` * `LEAFNODE` @@ -154,5 +153,5 @@ The possible values are currently: ## Leaf nodes connections -You can configure remote Leaf node connections so that they connect to the Websocket port instead of the Leaf node port. -See [Leafnode](../leafnodes/leafnode_conf.md#connecting-using-websocket-protocol) section. +You can configure remote Leaf node connections so that they connect to the Websocket port instead of the Leaf node port. See [Leafnode](../leafnodes/leafnode_conf.md#connecting-using-websocket-protocol) section. + diff --git a/whats_new_22.md b/whats_new_22.md index f197acb..00bea6c 100644 --- a/whats_new_22.md +++ b/whats_new_22.md @@ -39,7 +39,7 @@ Now you can specify [default user permissions](nats-server/configuration/securin ## WebSockets -Connect mobile and web applications to any NATS server using [WebSockets](nats-server/configuration/websocket.md). Built to more easily traverse firewalls and load balancers, NATS WebSocket support provides even more flexibility to NATS deployments and makes it easier to communicate to the edge and endpoints. This is currently supported in NATS server leaf nodes, nats.ts, nats.deno, and the nats.js clients. +Connect mobile and web applications to any NATS server using [WebSockets](nats-server/configuration/websocket/). Built to more easily traverse firewalls and load balancers, NATS WebSocket support provides even more flexibility to NATS deployments and makes it easier to communicate to the edge and endpoints. This is currently supported in NATS server leaf nodes, nats.ts, nats.deno, and the nats.js clients. ## Native MQTT Support