Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Publish Problems
  • From: Alvares Felipe <felipe.alvares@xxxxxxxxxxxxxxxxxx>
  • Date: Tue, 22 Nov 2022 14:52:40 +0000
  • Accept-language: pt-BR, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irricontrol.com.br; dmarc=pass action=none header.from=irricontrol.com.br; dkim=pass header.d=irricontrol.com.br; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=avLYnpESr6CCDAmmWycEqsByy3zs04s3Qs9Kq/YB+Ag=; b=inE6AGwWlVa8NyG2gZHm6Gqafi/pmdAyDbL32VWnbFgtbVgLJEy526xEs+7b7nCSEdeo16CEIliCEo9aHYfz69QztQcWZFqj5zEVRPWMFsrJZnAPKLS65zsQIJPRU7Z6UG18hsxPf/jnLxc5Zg0wS6qu2mzEpe/h4JT/e1JXOOHhO6AySaF9J3Q0IBqIP0Ru6mpyA9e4/dcqqsbMzGrdL2masRg87RxOiEB1F4CUVV6t5eFkXoQtzhnxWAhGLjuAVX+RABxtxGj31RyHyZZfQiKpZTnmf/Muxura9zNByomjlKiwqCkqaJA3CrTOvqgS3z1AfLpZsxB2cm6FnbDo3A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LXdDQJgtkJT+/tc+QTuC2jA5CUIFV6OF0SAjasEqJ70ewbKxOmKQ+9CFCDB1wbjQXqFyb++8qKaiGjxlxbm9DHTlMV5Xw+JtaMKG1BRhx1ptVTg5emura7PHZM01+vYK6TmuM/DKAN1zZRzkG2r67xn4aZk06P7XNEQv2GYMISCPpcPaq8sdVtlGBZxEmDmFnGw1PnIUwXzGFG9XHUabRqDnbJ62hMyyLI1oDSSr4PrqtUD3OpTkm+p+fj9CPN52MgoJDOwripFXpdYm+a27RZQpShtkQ9urVwWt/puz823M2kWgAqGs1zoSgy0BSUIrM76PqPiAfIurI+SK2rB/lA==
  • Delivered-to: paho-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/paho-dev/>
  • List-help: <mailto:paho-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/paho-dev>, <mailto:paho-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/paho-dev>, <mailto:paho-dev-request@eclipse.org?subject=unsubscribe>
  • Msip_labels:
  • Thread-index: AQHY/oH5FBwYiIlGyU6hl4P06ir/Jw==
  • Thread-topic: Publish Problems

Hi guys,

I'm working on a project that I get some informations in a raspberry and sent it to my broker.
Mostly times it works, but in some devices after a time operating it receive messages from topic, but it can't publish.
Actually in the code the script run the publish line but dosen't  generate any error, and when I'm listening the topic doesn't reach any message.

Language: Python 3.9
paho-mqtt version: 1.6.1

Some code:
class Mqtt:
    def __init__(self, base_id):
        self.base_id = base_id
        # client settings
        self.client = mqtt.Client(client_id=self.base_id, clean_session=True, userdata=None,
                                  protocol=mqtt.MQTTv31)
        self.client.username_pw_set(username=MQTT_USER, password=MQTT_PASS)
        self.mqtt_web_conected = False
        # connection calllbacks
        self.client._on_connect_ = self.on_connect
        self.client._on_disconnect_ = self.on_disconnect
        self.connected_once = False
def connect(self):
    # connect to broker
    # @params void
    # @return void
    try:
        self.client.connect(host=MQTT_HOST, port=MQTT_PORT, keepalive=KEEP_ALIVE, bind_address='')
        self.client.loop_start()
        self.mqtt_web_conected = True

        last_will_topic = STREAMS_PUBLISH_TOPIC + "/" + self.base_id
        value = get_hex_timestamp() + b'\x17\x09\x90'
        value = base64.encodebytes(value)
        self.client.will_set(topic=last_will_topic, payload=value, qos=2, retain=False)
    except Exception as e:
        print(e)
        self.mqtt_web_conected = False
def publish_payload(self, value, topic):
    # publish a payload
    # @params value: bytes
    # @return 1 or 0 based if msg was sent or not

    # encodes msg in base 64
    value = base64.encodebytes(value)
    topic = topic + self.base_id
    result, mid = self.client.publish(topic, value, qos=2)
    return result
Has anyone seem an error like this?


Att,
profile-image

Felipe Alvares

JR ELECTRONIC ENGINEER

+55 (12) 99119-6104

felipe.alvares@irricontrol.com.br

logo-irricontrol




Back to the top