Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python paho mqtt library does not require verification when inserting data through the mqtt protocol #1446

Closed
kqkdChen opened this issue Jul 1, 2020 · 1 comment

Comments

@kqkdChen
Copy link

kqkdChen commented Jul 1, 2020

一、我修改了root用户密码,并且重启了server
二、使用 python paho mqtt 插入数据时,没有设置用户名和密码相关参数
三、但是我仍然成功的插入了数据 -_-!!!

iotdb version: 0.10.0
paho mqtt: 1.5.0 (pip install paho-mqtt)

代码如下:

from time import *
import paho.mqtt.publish as publish


def timestamp():
    return int(round(time() * 1000))


def single(tx_id: str, log_type: str, log_content: str, hostname: str = "192.168.3.181", port: int = 1883):
    device_id = "root.log.%s" % tx_id
    payload = "{\n" "\"device\":\"%s\",\n" "\"timestamp\":%d,\n" "\"measurements\":[\"type\",\"content\"],\n" "\"values" \
              "\":[\"%s\",\"%s\"]\n" "}" % (device_id, timestamp(), log_type, log_content)
    publish.single(topic=device_id, payload=payload, hostname=hostname, port=port)


if __name__ == '__main__':
    type_list = ["INFO", "WARNING", "ERROR"]
    content_list = ["自动上报: 组件不完整", "日志同步", "命令长度校验失败", "配置参数有误"]
    begin_time = time()
    for i in range(10):
        single("1411111111", type_list[i % len(type_list)], content_list[i % len(content_list)])
    end_time = time()
    run_time = end_time - begin_time
    print('该循环程序运行时间:', run_time)
@vesense
Copy link
Member

vesense commented Jul 2, 2020

Fixed by #1447

@vesense vesense closed this as completed Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants