paho

MQTT over websocket in python

主宰稳场 提交于 2019-12-21 21:56:05
问题 is there any support in python to subscribe on mqtt broker with port 8080 import sys import paho.mqtt.client as mqtt def on_connect(mqttc, obj, flags, rc): print("rc: "+str(rc)) def on_message(mqttc, obj, msg): print(msg.topic+" "+str(msg.qos)+" "+str(msg.payload)) def on_publish(mqttc, obj, mid): print("mid: "+str(mid)) def on_subscribe(mqttc, obj, mid, granted_qos): print("Subscribed: "+str(mid)+" "+str(granted_qos)) def on_log(mqttc, obj, level, string): print(string) mqttc = mqtt.Client()

Very slow network performance of Docker containers with host's network

烈酒焚心 提交于 2019-12-21 12:29:44
问题 I'm having a problem with sluggish network performance between Docker containers and host's network. I asked this question on the Docker's forum but have received no answers so far. Problem Set-up: two Macs on the same local network; the first runs an MQTT broker (mosquitto); the second runs Docker for Mac. Two C++ programs run on the second Mac and exchange data multiple times through the MQTT broker (on the first Mac), using the Paho MQTT C library. Native run: when I ran the two C++

golang mqtt publish and subscribe

半腔热情 提交于 2019-12-21 04:41:02
问题 Does anybody know where I can get some example MQTT client Go (golang) code that does both publish and subscribe in an infinite loop ? I am messaging with a Mosquitto broker running on MacOs. In more detail... Get a message from the network (a topic) Compute something based on that message Send the result of the computation back to the network (topic) Here is the code I am using: package main import ( "fmt" MQTT "github.com/eclipse/paho.mqtt.golang" "os" "time" ) var knt int var f MQTT

Python Paho MQTT: Unable to publish immediately in a function

ぐ巨炮叔叔 提交于 2019-12-20 03:13:57
问题 I am implementing a program that listen to a specific topic and react to it when a new message is published by my ESP8266. When a new message is received from ESP8266, my program will trigger the callback and perform a set of tasks. I am publishing two messages in my callback function back to the topic that the Arduino is listening. However, the messages are published only after the function exits. Thank you for all your time in advance. I have tried to use loop(1) with a timeout of 1 second

android - Paho MQTT service for publishing

Deadly 提交于 2019-12-17 23:37:38
问题 I am new to Android and services. My aim is to be able to set-up subscriptions and do publications on topic strings. The topic strings and client ID are set-up after parsing input of text fields. I am using the Paho MQTT service (downloaded the source and built the JAR). The following causes a Null Pointer Exception at c.publish() . The logcat shows the exception at the IMqttDeliveryToken publish(String topic, MqttMessage message, Object userContext, IMqttActionListener callback) method in

Two paho.mqtt clients subscribing to the same client localy

旧时模样 提交于 2019-12-14 03:21:25
问题 I'm trying to find out if it is possible to have two paho.mqtt clients (https://eclipse.org/paho/clients/python/docs/) subscribing to the same server. Both clients and server are running on the same host. My aim is to have two clients subscribing with different credentials to the same server (which in my case is rabbitmq with mqtt plugin) so I can sort my payloads by vhosts (not by topic since I don't have control over topics). My observation at the moment is that the clients just keep

MQTT know if a client is subscribed

。_饼干妹妹 提交于 2019-12-13 07:15:49
问题 The question is already posted, Mqtt How a client can get to know that another client is connected or not and How to Find Connected MQTT Client Details In my case, if client X is already subscribed in a channel A, client Y can't subcribe to the channel A, until X unsubcribes. I can only have one client subscribed in the channel Can I also use the idea of retained messages and LWT? If yes, I don't know exactly from where should I start. It would be good to start with a simple example to see

How do you send a PINGREQ in python for paho mqtt?

空扰寡人 提交于 2019-12-13 03:25:04
问题 I connect to my mosquitto broker with client.connect("192.168.1.1",1883,60) to establish the connection, and the server expects traffic every 60 seconds. The paho documentation refers to a PINGREQ/PINGACK message which I would like to use to keep the connection alive. Can't find any examples of this - how to do this in python (2.7)? 回答1: The short answer is you don't The pings are handled by the MQTT Client network loop. You need to start this after connecting. There are 3 ways to run the

Python 3 Paho-MQTT Published/Subscribed JSON message won't parse

故事扮演 提交于 2019-12-13 02:49:37
问题 Rookie here. I have a simple python code that's supposed to subscribe to a topic and publish JSON payload to the same topic using MQTT protocol. But for some reason, I am unable to load the payload as JSON! What am I doing wrong here? # -*- coding: utf-8 -*- import paho.mqtt.client as mqtt import json mqtt_broker = '192.168.1.111' mqtt_topic_one = 'mqtt_topic/tops_one' mqtt_topic_two = 'mqtt_topic/tops_two' json_data_1 = '''{ "this_json": "info", "data": { "multi_keyval": { "1": "1", "5": "5"

Paho Rabitmqq connection getting failed

会有一股神秘感。 提交于 2019-12-12 03:26:47
问题 Here is my paho client code // Create a client instance client = new Paho.MQTT.Client('127.0.0.1', 1883, "clientId"); // set callback handlers client.onConnectionLost = onConnectionLost; client.onMessageArrived = onMessageArrived; // connect the client client.connect({onSuccess:onConnect}); // called when the client connects function onConnect() { // Once a connection has been made, make a subscription and send a message. console.log("onConnect"); client.subscribe("/World"); message = new