diff --git a/weevent-broker/src/main/java/com/webank/weevent/broker/protocol/mqtt/ProtocolProcess.java b/weevent-broker/src/main/java/com/webank/weevent/broker/protocol/mqtt/ProtocolProcess.java index d35225e84..f64188d5c 100644 --- a/weevent-broker/src/main/java/com/webank/weevent/broker/protocol/mqtt/ProtocolProcess.java +++ b/weevent-broker/src/main/java/com/webank/weevent/broker/protocol/mqtt/ProtocolProcess.java @@ -221,8 +221,8 @@ public Optional process(MqttMessage req, String sessionId, String r } } if (!isAuth) { - log.error("userName:{},topicName:{}, not publish permission", userName, topicName); - throw new BrokerException(ErrorCode.MQTT_NOT_PERMISSION); + log.error("userName:{},topicName:{}, no publish permission", userName, topicName); + throw new BrokerException(ErrorCode.MQTT_NO_PUB_PERMISSION); } } @@ -236,12 +236,12 @@ public Optional process(MqttMessage req, String sessionId, String r if (null != entity && (entity.getPermission() == SUB_PUB || entity.getPermission() == PUB)) { continue; } - log.error("userName:{},topicName:{}, not subscribe permission", userName, topicName); + log.error("userName:{},topicName:{}, no subscribe permission", userName, topicName); isAuth = false; break; } if (!isAuth) { - throw new BrokerException(ErrorCode.MQTT_NOT_PERMISSION); + throw new BrokerException(ErrorCode.MQTT_NO_SUB_PERMISSION); } } diff --git a/weevent-broker/src/main/resources/script/broker_h2.sql b/weevent-broker/src/main/resources/script/broker_h2.sql index a0f4a823b..dcfd91cd9 100644 --- a/weevent-broker/src/main/resources/script/broker_h2.sql +++ b/weevent-broker/src/main/resources/script/broker_h2.sql @@ -20,7 +20,7 @@ create TABLE t_account_topic_auth( create_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) -) +); alter table t_account add CONSTRAINT userName UNIQUE (user_name); alter table t_account_topic_auth add CONSTRAINT userNameTopicName UNIQUE (user_name, topic_name); \ No newline at end of file diff --git a/weevent-broker/src/main/resources/weevent.properties b/weevent-broker/src/main/resources/weevent.properties index 0384c6dad..8549f850c 100644 --- a/weevent-broker/src/main/resources/weevent.properties +++ b/weevent-broker/src/main/resources/weevent.properties @@ -7,7 +7,7 @@ block.chain.type=fisco #stomp heartbeats stomp.heartbeats=30 #mqtt broker -mqtt.broker.tcp.port=7001 +#mqtt.broker.tcp.port=7001 mqtt.broker.keepalive=60 mqtt.broker.security.ssl=false mqtt.broker.security.ssl.client_auth=false diff --git a/weevent-client/src/main/java/com/webank/weevent/client/ErrorCode.java b/weevent-client/src/main/java/com/webank/weevent/client/ErrorCode.java index c965ddc33..70525b757 100644 --- a/weevent-client/src/main/java/com/webank/weevent/client/ErrorCode.java +++ b/weevent-client/src/main/java/com/webank/weevent/client/ErrorCode.java @@ -152,8 +152,9 @@ public enum ErrorCode { MQTT_CONNECT_CONFLICT(200610, "connect command conflict with specification 3.1.1"), MQTT_UNKNOWN_CLIENT_ID(200611, "unknown client id"), MQTT_NOT_SUPPORT_QOS2(200612, "do not support qos=2"), - MQTT_NOT_PERMISSION(200613, "not permission"), - MQTT_SSL_ERROR(200614, "mqtt get ssl context error"), + MQTT_NO_SUB_PERMISSION(200613, "no suscribe permission"), + MQTT_NO_PUB_PERMISSION(200614, "no publish permission"), + MQTT_SSL_ERROR(200615, "mqtt get ssl context error"), FTP_INVALID_USERNAME_PASSWD(200700, "invalid username or password"),