1
0
mirror of https://github.com/taigrr/nats.docs synced 2025-01-18 04:03:23 -08:00

GitBook: [master] 210 pages modified

This commit is contained in:
Ginger Collison
2021-03-29 16:42:40 +00:00
committed by gitbook-bot
parent cf8e261962
commit 14a3fd1f44
5 changed files with 31 additions and 21 deletions

View File

@@ -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

View File

@@ -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/).

View File

@@ -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.