mqtt_client.py 590 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
  5. @AUTHOR: ASJRD018
  6. @NAME: AnsjerFormal
  7. @software: PyCharm
  8. @DATE: 2019/3/7 9:43
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: mqtt_client.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. import paho.mqtt.client as mqtt
  15. HOST = "192.168.136.45"
  16. PORT = 1883
  17. def test():
  18. client = mqtt.Client()
  19. client.connect(HOST, PORT, 60)
  20. client.publish("chat", "hello chenfulin11111", 2)
  21. # client.loop()
  22. client.loop_forever()
  23. if __name__ == '__main__':
  24. test()