You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/12/06 13:39:28 UTC

[GitHub] [iotdb] jerrychong25 commented on issue #1442: failed to insert data using python paho mqtt library

jerrychong25 commented on issue #1442:
URL: https://github.com/apache/iotdb/issues/1442#issuecomment-1339403670

   > 单次发送
   > 
   > ```python
   > 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报错。
   
   Python MQTT Client代码:
   ![58baa2b462a3869a1fd8163be9dc24e](https://user-images.githubusercontent.com/15714095/205927063-fb524eb8-7b19-47d1-964d-0a22892f65da.png)
   
   IoTDB MQTT Configuration:
   ![0399e3cb358d0201046bcaabb2f0e8d](https://user-images.githubusercontent.com/15714095/205927189-2c0c1950-bed4-4afc-935b-77665b17b215.png)
   
   也尝试使用**apache-iotdb** pypi library **session.insert_record()** 测试存入一样的Records,IoTDB成功保存。
   
   这个问题要怎么解决呢?
   
   谢谢!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org