Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apisix/stream/plugins/mqtt-proxy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ end)
local schema = {
type = "object",
properties = {
protocol_name = {type = "string"},
protocol_name = {type = "string", default = "MQTT"},
protocol_level = {type = "integer"}
},
required = {"protocol_name", "protocol_level"},
required = {"protocol_level"},
}


Expand Down Expand Up @@ -156,8 +156,9 @@ function _M.preread(conf, ctx)
return 503
end

if res.protocol and res.protocol ~= conf.protocol_name then
core.log.error("expect protocol name: ", conf.protocol_name,
local protocol_name = conf.protocol_name or "MQTT"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No default value is needed here since we've already defined the default value in the schema.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tysoncung, please take a look

if res.protocol and res.protocol ~= protocol_name then
core.log.error("expect protocol name: ", protocol_name,
", but got ", res.protocol)
return 503
end
Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/plugins/mqtt-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This Plugin supports both the protocols [3.1.*](http://docs.oasis-open.org/mqtt/

| Name | Type | Required | Description |
|----------------|---------|------------|-----------------------------------------------------------------------------------|
| protocol_name | string | True | Name of the protocol. Generally `MQTT`. |
| protocol_name | string | False | Name of the protocol. Defaults to `MQTT`. |
| protocol_level | integer | True | Level of the protocol. It should be `4` for MQTT `3.1.*` and `5` for MQTT `5.0`. |

## Enable Plugin
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/latest/plugins/mqtt-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ description: 本文档介绍了 Apache APISIX mqtt-proxy 插件的信息,通

| 名称 | 类型 | 必选项 | 描述 |
| -------------- | ------- | ----- | ------------------------------------------------------ |
| protocol_name | string | | 协议名称,正常情况下应为 `MQTT`。 |
| protocol_name | string | | 协议名称,默认为 `MQTT`。 |
| protocol_level | integer | 是 | 协议级别,MQTT `3.1.*` 为 `4`,MQTT `5.0` 应是`5`。 |

## 启用插件
Expand Down