1
0
mirror of https://github.com/balkian/mqtt-poc.git synced 2024-12-22 12:58:12 +00:00
mqtt-poc/python-clients/mqtt-producer.py

20 lines
402 B
Python
Raw Normal View History

2018-02-22 16:38:21 +00:00
import paho.mqtt.publish as publish
import os
import time
import socket
HOSTNAME = socket.gethostname()
HOST = os.environ.get('MQTT_HOST', 'localhost')
print('Connecting to %s' %HOST)
topic = "/gsi/test/multiple"
i = 0
while True:
print('%s pushing msg %s' %(HOSTNAME, i))
publish.single(topic=topic, payload='%s says %s' %(HOSTNAME, i), qos=1, hostname=HOST)
i += 1
time.sleep(2)