paho

Windows-mqtt本机broker构建

北慕城南 提交于 2021-02-11 08:31:49
注:仅仅作为个人笔记所用。 一、下载 apache-apollo-1.7.1-windows-distro.zip 这个压缩包,官网的我没找着,这里有个:http://archive.apache.org/dist/activemq/activemq-apollo/1.7.1/?C=N;O=A 二、解压缩之后,Windows + cmd 一直 cd 到 apache-apollo-1.7.1 文件夹下的 bin 文件夹,输入命令 apollo.cmd create mybroker,回车,这里的 mybroker 是在这个 bin 目录下新建文件夹的文件名。 如上图,mybroker 一开始是没有的。 三、cd 到 mybroker 的 bin 目录下,输入命令 apollo-broker.cmd run,回车。 备注:这里我测试时用的是 mqtt-client 的 api 写的。主要的参考网址:https://www.cnblogs.com/chenrunlin/p/5109028.html。有一点需要特别注意的是,这个broker Java 的 10.0.2 的版本是运行不起来的,Java 1.8 版本是 OK 的。 下面是 copy 上述网址的代码。 client: package maven_test.mqtt_test; // import java.util

mosquitto broker retain multiple messages

戏子无情 提交于 2021-02-08 10:20:18
问题 I am having mosquitto broker running on Ubuntu on EC2. Also I did a change max_queued_messages 1000 and max_inflight_messages 10 in /etc/mosquitto/mosquitto.conf I am publishing to this broker with qos=2 and retain enabled . For publishing I am using mosquitto_pub -t 1 -m "{c:{d:\"pN\",m:\"Pr1\"}}" -r -q 2 . And subscriber side I am using org.eclipse.paho.android.service:1.0.2 library with same qos=2. and only providing single option by options.setMqttVersion(MqttConnectOptions.MQTT_VERSION_3

Python mqtt client which tries to connect to broker when no internet

痴心易碎 提交于 2021-02-08 09:34:29
问题 I have somewhat unstable wifi network at home. I have pyhon code running on raspberry pi which tries to connect to "test.mosquitto.com" broker. Below is the python code which I have written import time import paho.mqtt.client as mqtt bConnected = False def on_disconnect(client, userdata, msg): print "Disonnected from broker" global bConnected bConnected = False def on_connect(client, userdata, msg): print "Connected to broker" global bConnected bConnected = True def worker_thread(): ""

How to subscribe and publish parallel in Paho-MQTT python?

≯℡__Kan透↙ 提交于 2021-01-29 22:15:00
问题 I'm working with the paho-mqtt client and wondering if anybody of you can help me subscribing and publishing messages parallel. My Setup: I've got a couple of sensors writing data into an InfluxDB. Using subscriptions with some parameters (time, start of recording) I can afterwards get the sensordata out of the InfluxDB. I've wrote a script which subscribes to all sensors/# and hands me a list of all avalible sensors in my system, which leads me directly to my question: My Problem: Now I've

Camel PAHO routes not receiving offline messages while connecting back

蹲街弑〆低调 提交于 2021-01-29 19:13:52
问题 I'm using apache camel xml based paho routes for the subscription, publication process. While online, everything works fine. But I'm not able to receive the offline message. I have set the following., Constant Client ID Clean Session is FALSE, Both subscribed & published with QoS 2 With the standalone Program, it's getting all the offline messages. With the camel route it's not happening. 回答1: Finally, I was able to solve this one manually. Camel PAHO Client is not populating the callback

Offline messages not being send to adafruit iot portal by mosquitto broker

旧巷老猫 提交于 2021-01-28 05:11:18
问题 I have a raspberry pi in which I have installed mosquitto broker and mqtt. Pi is connected to sensor and I need to send this data to adafruit IOT protal . I am able to send all the data when the pi is connected but when the pi goes offline, I am only able to transmit data for 20-30 sec. If the pi is offline for more than 2-3 mins then that data is not transmitted to portal. I have created a bridge.conf file and add all the configurations to be used my mosquitto. Here is the content:

Google Cloud IoT - Invalid MQTT publish topic

非 Y 不嫁゛ 提交于 2021-01-28 04:25:14
问题 I am using a Python client with paho-mqtt to publish in this specific topic of Google Cloud IoT: projects/my_project/topics/sm1 . My code is below, based on examples of the Google IoT documentation: import paho.mqtt.client as mqtt import ssl, random, jwt_maker from time import sleep root_ca = './../roots.pem' public_crt = './../my_cert.pem' private_key = './../my_pr.pem' mqtt_url = "mqtt.googleapis.com" mqtt_port = 8883 mqtt_topic = "/projects/my_project/topics/sm1" project_id = "my_project"

Google Cloud IoT - Invalid MQTT publish topic

ぐ巨炮叔叔 提交于 2021-01-28 04:00:56
问题 I am using a Python client with paho-mqtt to publish in this specific topic of Google Cloud IoT: projects/my_project/topics/sm1 . My code is below, based on examples of the Google IoT documentation: import paho.mqtt.client as mqtt import ssl, random, jwt_maker from time import sleep root_ca = './../roots.pem' public_crt = './../my_cert.pem' private_key = './../my_pr.pem' mqtt_url = "mqtt.googleapis.com" mqtt_port = 8883 mqtt_topic = "/projects/my_project/topics/sm1" project_id = "my_project"

Compile PahoMqttCpp sample as standalone with cmake on Linux

柔情痞子 提交于 2020-12-27 06:54:07
问题 My goal ... is to use the sample code async_subscribe.cpp from the PahoMqttCpp project (https://github.com/eclipse/paho.mqtt.cpp) as a standalone application to then modify it for my needs. My approach Preliminaries On the newest model of Raspberry pi ( uname -a --> 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux ) I have followed the description in the PahoMqttCpp README.md file. I compiled successfully the C-library (v1.2.1) and then compiled successfuly the Cpp part,

mqtt mosquitto 安装与使用

风格不统一 提交于 2020-11-30 23:24:40
1,安装服务端 mosquitto apt-get install mosquitto 2,安装客户端paho.mqtt.python pip install paho-mqtt 3, mqtt 应用在ubuntu上 import paho.mqtt.client as mqtt import time HOST="127.0.0.1"//mosquitto 安装的主机ip,127.0.0.1 表示与mosquitto在同一机器上 PORT=1883 client=mqtt.Client() def on_connect(client,userdata,msg): print("on_connect") pass def on_dis_connect(client,userdata,msg): print("on_dis_connect") pass def mqtt_sub(topic): client.subscribe(topic,1) def mqtt_pub(topic,payload): client.publish(topic,payload,1,1) def mqtt_init(on_message): client.connect(HOST,PORT,60) client.on_connect=on_connect client.on_disconnect=on