Copilot commented on code in PR #13972:
URL: https://github.com/apache/apisix/pull/13972#discussion_r4052331944


##########
apisix/plugins/websocket-proxy.lua:
##########
@@ -0,0 +1,63 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local core = require("apisix.core")
+
+
+-- "client"/"upstream" here name the same two roles resty.websocket.proxy
+-- itself uses: "client" is the side facing the real downstream WebSocket
+-- client, "upstream" is the side facing the backend. Left unset, the
+-- library defaults max_payload_len (and, through it, the max size of a
+-- single unfragmented frame) to 65535 on both sides.
+local schema = {
+    type = "object",
+    properties = {
+        client_max_payload_len = {
+            type = "integer",
+            minimum = 1,

Review Comment:
   Both properties accept arbitrarily large integers, but 
`api7-lua-resty-websocket` 0.2.0 explicitly supports frame lengths only up to 
`0x7fffffff`. Larger values therefore pass route validation even though the 
proxy can never honor them. Add `maximum = 2147483647` to both properties and 
document that bound.
   
   This issue also appears on line 31 of the same file.



##########
docs/en/latest/plugins/websocket-proxy.md:
##########
@@ -0,0 +1,89 @@
+---
+title: websocket-proxy
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - WebSocket proxy
+description: This document contains information about the Apache APISIX 
websocket-proxy Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `websocket-proxy` plugin configures advanced parameters for a route whose 
`upstream.scheme` is
+`ws` or `wss`. It currently controls the maximum size of a single WebSocket 
frame APISIX accepts on
+each side of the connection.
+
+By default, APISIX accepts a single frame of up to 65535 bytes from either the 
downstream client or
+the upstream; a larger single frame closes the connection. `enable_websocket` 
has no such limit,
+since it lets nginx relay raw bytes without parsing frames, but `scheme: 
ws`/`wss` parses every
+frame in order to run plugin logic against it, and the underlying library caps 
a single frame's size
+unless told otherwise. This plugin raises that cap for routes that need to 
send or receive larger
+messages, such as a client uploading a file in one WebSocket message.
+
+## Attributes
+
+| Name                      | Type    | Required | Default | Valid values | 
Description |
+|---------------------------|---------|----------|---------|--------------|-------------|
+| client_max_payload_len    | integer | optional |         | >= 1         | 
Max size, in bytes, of a single WebSocket message this route accepts from the 
downstream client. Left unset, the default of 65535 applies. |
+| upstream_max_payload_len  | integer | optional |         | >= 1         | 
Max size, in bytes, of a single WebSocket message this route accepts from the 
upstream. Left unset, the default of 65535 applies. |

Review Comment:
   These are endpoint-level send/receive frame limits, not independent limits 
on messages received from each peer. As written, users may set only 
`client_max_payload_len` for large client frames, but forwarding still fails 
against the upstream endpoint's default send limit. Document the endpoint 
semantics so asymmetric configurations are not misleading.



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