Skip to content

Commit 4d09a8c

Browse files
authored
out_websocket: doc change with PR #3010 (#455)
Signed-off-by: Fenggang <[email protected]>
1 parent c711cc6 commit 4d09a8c

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

pipeline/outputs/websocket.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ The **websocket** output plugin allows to flush your records into a WebSocket en
1212
| Format | Specify the data format to be used in the HTTP request body, by default it uses _msgpack_. Other supported formats are _json_, _json\_stream_ and _json\_lines_ and _gelf_. | msgpack |
1313
| json\_date\_key | Specify the name of the date field in output | date |
1414
| json\_date\_format | Specify the format of the date. Supported formats are _double_ and _iso8601_ \(eg: _2018-05-30T09:39:52.000681Z_\) | double |
15-
| idle\_interval | The interval that websocket output plugin would keep to decide if it is OK to reconnet to Websocket Server | 20 |
1615

1716
## Getting Started
1817

@@ -48,12 +47,10 @@ In your main configuration file, append the following _Input_ & _Output_ section
4847
Port 80
4948
URI /something
5049
Format json
51-
Idle_interval 21
5250
```
5351

54-
Suggested configuration for Idle Interval is 20. Websocket plugin is working with tcp keepalive mode, please refer to [networking](https://docs.fluentbit.io/manual/v/master/administration/networking#configuration-options) section for details.
52+
Websocket plugin is working with tcp keepalive mode, please refer to [networking](https://docs.fluentbit.io/manual/v/master/administration/networking#configuration-options) section for details. Since websocket is a stateful plugin, it will decide when to send out handshake to server side, for example when plugin just begins to work or after connection with server has been dropped. In general, the interval to init a new websocket handshake would be less than the keepalive interval. With that stratgy, it could detect and resume websocket connetions.
5553

56-
By default, if there is no traffic for about 30 seconds, fluent-bit would abort the tcp connection. As a result, if websocket would like to send data to the same server again, it has to reconnect. This parameter is to help to determine if websocket need to reconnect or not.
5754

5855
## Testing
5956

@@ -69,10 +66,12 @@ By default, if there is no traffic for about 30 seconds, fluent-bit would abort
6966
Name websocket
7067
Match *
7168
Host 127.0.0.1
72-
Port 9000
69+
Port 8080
7370
URI /
7471
Format json
75-
Idle_interval 21
72+
workers 4
73+
net.keepalive on
74+
net.keepalive_idle_timeout 30
7675
```
7776

7877
Once Fluent Bit is running, you can send some messages using the _netcat_:
@@ -84,27 +83,42 @@ $ echo '{"key 1": 123456789, "key 2": "abcdefg"}' | nc 127.0.0.1 5170; sleep 35;
8483
In [Fluent Bit](http://fluentbit.io) we should see the following output:
8584

8685
```bash
87-
bin/fluent-bit -c ../conf/out_ws.conf
88-
Fluent Bit v1.5.0
86+
bin/fluent-bit -c ../conf/out_ws.conf
87+
Fluent Bit v1.7.0
8988
* Copyright (C) 2019-2020 The Fluent Bit Authors
9089
* Copyright (C) 2015-2018 Treasure Data
9190
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
9291
* https://fluentbit.io
9392

94-
[2020/07/07 03:39:31] [ info] [storage] version=1.0.4, initializing...
95-
[2020/07/07 03:39:31] [ info] [storage] in-memory
96-
[2020/07/07 03:39:31] [ info] [storage] normal synchronization mode, checksum disabled, max_chunks_up=128
97-
[2020/07/07 03:39:31] [ info] [engine] started (pid=12734)
98-
[2020/07/07 03:39:31] [ info] [input:tcp:tcp.0] listening on 0.0.0.0:5170
99-
[2020/07/07 03:39:31] [ info] [out_ws] we have following parameter /, 127.0.0.1, 9000, 22
100-
[2020/07/07 03:39:31] [ info] [sp] stream processor started
101-
[2020/07/07 03:39:36] [ info] [out_ws] handshake for ws
102-
[2020/07/07 03:40:11] [ warn] [engine] failed to flush chunk '12734-1594107609.72852130.flb', retry in 6 seconds: task_id=0, input=tcp.0 > output=websocket.0
103-
[2020/07/07 03:40:17] [ info] [out_ws] handshake for ws
104-
[2020/07/07 03:40:17] [ info] [engine] flush chunk '12734-1594107609.72852130.flb' succeeded at retry 1: task_id=1, input=tcp.0 > output=websocket.0
93+
[2021/02/05 22:17:09] [ info] [engine] started (pid=6056)
94+
[2021/02/05 22:17:09] [ info] [storage] version=1.1.0, initializing...
95+
[2021/02/05 22:17:09] [ info] [storage] in-memory
96+
[2021/02/05 22:17:09] [ info] [storage] normal synchronization mode, checksum disabled, max_chunks_up=128
97+
[2021/02/05 22:17:09] [ info] [input:tcp:tcp.0] listening on 0.0.0.0:5170
98+
[2021/02/05 22:17:09] [ info] [out_ws] we have following parameter /, 127.0.0.1, 8080, 25
99+
[2021/02/05 22:17:09] [ info] [output:websocket:websocket.0] worker #1 started
100+
[2021/02/05 22:17:09] [ info] [output:websocket:websocket.0] worker #0 started
101+
[2021/02/05 22:17:09] [ info] [sp] stream processor started
102+
[2021/02/05 22:17:09] [ info] [output:websocket:websocket.0] worker #3 started
103+
[2021/02/05 22:17:09] [ info] [output:websocket:websocket.0] worker #2 started
104+
[2021/02/05 22:17:33] [ info] [out_ws] handshake for ws
105+
[2021/02/05 22:18:08] [ warn] [engine] failed to flush chunk '6056-1612534687.673438119.flb', retry in 7 seconds: task_id=0, input=tcp.0 > output=websocket.0 (out_id=0)
106+
[2021/02/05 22:18:15] [ info] [out_ws] handshake for ws
107+
^C[2021/02/05 22:18:23] [engine] caught signal (SIGINT)
108+
[2021/02/05 22:18:23] [ warn] [engine] service will stop in 5 seconds
109+
[2021/02/05 22:18:27] [ info] [engine] service stopped
110+
[2021/02/05 22:18:27] [ info] [output:websocket:websocket.0] thread worker #0 stopping...
111+
[2021/02/05 22:18:27] [ info] [output:websocket:websocket.0] thread worker #0 stopped
112+
[2021/02/05 22:18:27] [ info] [output:websocket:websocket.0] thread worker #1 stopping...
113+
[2021/02/05 22:18:27] [ info] [output:websocket:websocket.0] thread worker #1 stopped
114+
[2021/02/05 22:18:27] [ info] [output:websocket:websocket.0] thread worker #2 stopping...
115+
[2021/02/05 22:18:27] [ info] [output:websocket:websocket.0] thread worker #2 stopped
116+
[2021/02/05 22:18:27] [ info] [output:websocket:websocket.0] thread worker #3 stopping...
117+
[2021/02/05 22:18:27] [ info] [output:websocket:websocket.0] thread worker #3 stopped
118+
[2021/02/05 22:18:27] [ info] [out_ws] flb_ws_conf_destroy
105119
```
106120

107121
### Scenario Description
108122

109-
From the output of fluent-bit log, we see that once data has been ingested into fluent bit, plugin would perform handshake. After a while, no data or traffic is undergoing, tcp connection has been abort. And then another piece of data arrived, a try fro websocket plugin has been triggered, following with another handshake and data flush.
123+
From the output of fluent-bit log, we see that once data has been ingested into fluent bit, plugin would perform handshake. After a while, no data or traffic is undergoing, tcp connection would been abort. And then another piece of data arrived, a retry for websocket plugin has been triggered, with another handshake and data flush.
110124

0 commit comments

Comments
 (0)