failed to insert data using python paho mqtt library
See original GitHub issue使用 python paho mqtt 插入数据时出现错误: client_id不能为空,且qos必须等于0,不然就会出现错误。
qos=1 or 2, 则会出现如下错误,结果就是预期应该插入10W条数据的结果只插入了20条数据
iotdb version: 0.10.0 paho-mqtt: 1.5.0
代码如下
import random
import paho.mqtt.client as mqtt
import time
def on_connect(client, userdata, flags, rc):
print("Connected with result code: " + str(rc))
def on_message(client, userdata, msg):
print(msg.topic + " " + str(msg.payload))
client = mqtt.Client(client_id=str(random.uniform(1, 10)))
# client = mqtt.Client()
client.username_pw_set("root", "root")
client.connect('127.0.0.1', 1883)
timestamp = lambda: int(round(time.time() * 1000))
for i in range(100000):
message = "{\n" "\"device\":\"root.log.d1\",\n" "\"timestamp\":%d,\n" "\"measurements\":[\"s1\"],\n" "\"values" \
"\":[%f]\n" "}" % (timestamp() + 1000 * i, random.uniform(1, 10))
client.publish('root.log.d1.info', payload=message, qos=0, retain=False)
client.disconnect()
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
failed to insert data using python paho mqtt library #1442
我想问在IoTDB Python Client遇到的MQTT Publish写入问题,我尝试写入2行Records但是IoTDB没成功保存。MQTT这里使用Port 2833,因为已有另一个MQTT Broker ...
Read more >Import Error: paho.mqtt.client not found - Stack Overflow
I think I have found the problem,. You have installed Python3 but for some reason the interpreter defaults to version 2.7 in Linux....
Read more >How to Use The Paho MQTT Python Client - Beginners Guide
In this tutorial we look at the Paho MQTT Python Client. Using an example python script and the online Mosquitto broker to subscribe...
Read more >IoT Platform:Use the Paho MQTT library for Python to connect ...
This function is used to obtain the following MQTT connection parameters: mqttUsername, mqttPassword, and mqttClientId. Input parameters: ...
Read more >How to use MQTT in Python (Paho) | EMQ
This article introduces how to use the Paho MQTT client library in the Python project, and implements connection, subscribe, messaging, etc of MQTT....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jerrychong25 你好,已经过去太久具体api用法我忘记了,但是我想说的是,监测一下client的
connect
、success
、error
等回调方法,判断连接是否成功。如下是一些使用MQTT服务器的建议:mqtt_hander_pool_size=1
请设置更大。在IotDB的MQTT组件里,消息的处理使用了一个无界队列缓冲,默认配置会导致消息堆积最终导致IotDB OOM,线上引发过血案,不知道他们修复这个不合理的地方没有。@kqkdChen 欢迎贡献example到官网用户手册。
修改
docs/UserGuide/Client/Programming - MQTT.md
,以及docs/zh/UserGuide/Client/Programming - MQTT.md
(英文版和中文版)并提交PR即可。例如,在该markdown末尾增加
等我们的ptyon 集成测试框架搞定后,会考虑把python的样例代码放入源码中,每次构建时进行测试,确保不出错。
Welcome to posting your examples to the official website. just modify
docs/UserGuide/Client/Programming - MQTT.md
anddocs/zh/UserGuide/Client/Programming - MQTT.md
.By the way, we are planning to develop the UT framework for Python, and after that, we may put the example codes to the source folder and consider it as a check step for each code repo update.