Comments (13)
单次发送
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 = ["content_1", "content_2", "content_3", "content_4"]
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('cost time:', run_time)
from iotdb.
目前官网的示例主要是Java,其他语言的Demo(如Python,C++等)比较欠缺,欢迎你把示例贡献到社区(可以提patch到documents),让更多人看到。
from iotdb.
@kqkdChen 欢迎贡献example到官网用户手册。
修改docs/UserGuide/Client/Programming - MQTT.md
,以及docs/zh/UserGuide/Client/Programming - MQTT.md
(英文版和中文版)并提交PR即可。
例如,在该markdown末尾增加
##Example (Python)
粘贴你的代码(要增加一些说明,尽可能让代码易懂)
等我们的ptyon 集成测试框架搞定后,会考虑把python的样例代码放入源码中,每次构建时进行测试,确保不出错。
Welcome to posting your examples to the official website. just modify docs/UserGuide/Client/Programming - MQTT.md
and docs/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.
from iotdb.
@jerrychong25
你好,已经过去太久具体api用法我忘记了,但是我想说的是,监测一下client的connect
、success
、error
等回调方法,判断连接是否成功。如下是一些使用MQTT服务器的建议:
- 编写client的回调方法,确认连接是否成功,以及定位连接异常。
mqtt_hander_pool_size=1
请设置更大。在IotDB的MQTT组件里,消息的处理使用了一个无界队列缓冲,默认配置会导致消息堆积最终导致IotDB OOM,线上引发过血案,不知道他们修复这个不合理的地方没有。
from iotdb.
Many thanks. @vesense can you have a look?
from iotdb.
Thanks @kqkdChen for your report. I will take a look ASAP.
from iotdb.
Thanks @kqkdChen for your report. I will take a look ASAP.
谢谢,这个插入错误的问题我已经解决了,然后你能先帮我看这个新问题吗?这个比较重要,涉及到mqtt连接的身份验证失效。 #1446
from iotdb.
qos=1 or 2, 则会出现如下错误,结果就是预期应该插入10W条数据的结果只插入了20条数据
@kqkdChen 这个问题已经好了?发生了什么?
from iotdb.
使用 python paho mqtt 插入数据时,没有设置用户名和密码相关参数仍然成功的插入了
这是由于当前默认允许匿名用户访问。这会存在一定的安全隐患,我会提一个patch来解决。
from iotdb.
qos=1 or 2, 则会出现如下错误,结果就是预期应该插入10W条数据的结果只插入了20条数据
@kqkdChen 这个问题已经好了?发生了什么?
我换了另外一种方法写了mqtt client端的代码,所以就没有出现上述的错误了,所以这个问题应该是代码编写不规范造成的。然后我希望官网可以多一些其他语言的demo,我也会展示我的代码,希望可以帮助更多的人
from iotdb.
@kqkdChen Thanks again for your report and look forward to your more feedback and contributions.
from iotdb.
单次发送
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 = ["content_1", "content_2", "content_3", "content_4"] 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('cost time:', run_time)
@kqkdChen 你好!
我想问在IoTDB Python Client遇到的MQTT Publish写入问题,我尝试写入2行Records但是IoTDB没成功保存。MQTT这里使用Port 2833,因为已有另一个MQTT Broker占用Port 1883。而且没有任何IoTDB报错。
也尝试使用apache-iotdb pypi library session.insert_record() 测试存入一样的Records,IoTDB成功保存。
这个问题要怎么解决呢?
谢谢!
from iotdb.
@jerrychong25 你好,已经过去太久具体api用法我忘记了,但是我想说的是,监测一下client的
connect
、success
、error
等回调方法,判断连接是否成功。如下是一些使用MQTT服务器的建议:
- 编写client的回调方法,确认连接是否成功,以及定位连接异常。
mqtt_hander_pool_size=1
请设置更大。在IotDB的MQTT组件里,消息的处理使用了一个无界队列缓冲,默认配置会导致消息堆积最终导致IotDB OOM,线上引发过血案,不知道他们修复这个不合理的地方没有。
好的,谢谢 @kqkdChen !
from iotdb.
Related Issues (20)
- Continuous downsampling HOT 1
- [Bug] 模糊查询 like 查询无法匹配所有满足条件的数据 HOT 3
- OpenSSL version for IoTDB-Client CPP Example build faliure HOT 4
- [Feature request] Optimized code ASTVisitor.java HOT 1
- [Bug] Inconsistency in query results based on the environment HOT 2
- [Bug] Failed to run start-cli.bat on Windows10 HOT 1
- How To backup/restore cluster HOT 2
- [Bug] iotdb 压缩线程处理异常之后,会无限处理错误数据。手动删除对应的序列也没用 HOT 7
- [Bug] insertTablet http api lost data event return SUCCESS_STATUS HOT 6
- [Bug] 应该不算是一个bug HOT 1
- grafana add new data sorce error HOT 2
- [Bug] 在Rocky Linux无法启动 HOT 1
- 突然停电后,iotdb重启失败 HOT 2
- [Bug] NPE when deleting timeseries via Java API HOT 3
- iotdb支持ambari组件 HOT 3
- For Hdfs Integrating with IoTDB no support document avilable for IoTdb higher version above 0.13.x HOT 1
- 昨天运行了半天,早上出现的问题ERROR o.a.t.s.TThreadPoolServer$WorkerProcess:258 HOT 4
- [Bug] 当IoTDB重启的时候,Session范例的连接IoTDB的代码,将无法再远程连接上IoTDB HOT 13
- 分组查询时,时间跨度过大会导致服务器崩溃 HOT 1
- [Bug] 写UDAF的时候,如果不加group by level就能正常接收参数,如果加了group by level就报301 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iotdb.