soulbird commented on code in PR #7581:
URL: https://github.com/apache/apisix/pull/7581#discussion_r935583386


##########
docs/zh/latest/plugins/limit-conn.md:
##########
@@ -136,3 +136,76 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 
'X-API-KEY: edd1c9f034335f13
 ```
 
 现在就已经移除了 limit-conn 插件了。其他插件的开启和移除也是同样的方法。
+
+## 对 WebSocket 连接限速
+
+Apache APISIX 支持 WebSocket 代理,我们可以使用 `limit-conn` 插件限制 WebSocket 连接的并发数。
+
+1、创建路由并启用 WebSocket 代理和 `limit-conn` 插件
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+    "uri": "/ws",
+    "enable_websocket":true,
+    "plugins": {
+        "limit-conn": {
+            "conn": 1,
+            "burst": 0,
+            "default_conn_delay": 0.1,
+            "rejected_code": 503,
+            "key_type": "var",
+            "key": "remote_addr"
+        }
+    },
+    "upstream": {
+        "type": "roundrobin",
+        "nodes": {
+            "127.0.0.1:1980": 1
+        }
+    }
+}'
+```
+
+上述路由在 `/ws` 上开启了 WebSocket 代理,并限制了 WebSocket 连接并发数 1,超过 1 个并发的 WebSocket 连接将返回 
`503` 拒绝请求。

Review Comment:
   How about "上述路由在 `/ws` 上开启了 WebSocket 代理,并限制了 WebSocket 连接并发数为 1" ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to