paho

App, service and mqtt crashes when wifi disconnects and wont reconnect

我与影子孤独终老i 提交于 2019-12-02 05:48:22
I'm making an app with a mqtt client and a background service that makes a notification when I get certain mqtt message. I use Paho library and service as the client and everything works perfectly as long as I am connected to wifi and the broker is on. I don't want access to the broker over internet so when no wifi is available the client is disconnected, the problem is that when the wifi connects again the mqtt client wont reconnect. I have tried many things but the latest test was to make a handler check if there is internet and if its via wifi, and if it is I start the mqtt server again. I

With the clear session flag set to FALSE, I am missing the published values

亡梦爱人 提交于 2019-12-01 14:12:35
Is anyone has a logical explanation why despite I have the clear session flage = false I do not receive the updated published message I am subscribed to while i am not connected to the broker? With the aorementioned flag set to false I ran my App, And i kept publishing to a topic some values (from the PC to the broker not from the Android device to the broker). And then I unpluged the usb of the Android Device frm the pc, and kept publishing some values again. When I plugged the usb to the pc again, i expected to see the values I recently published to that topic, but I did not receive any. The

How do I create a actor if I subscribe to a specific topic?

[亡魂溺海] 提交于 2019-12-01 12:27:24
Hi I have some code which includes publish/subscribe and actors. The generic_device class allows me to create other actors. I was wondering how do I create a specific actor from the generic_device class when I subscribe to a topic and if the topic isn't subscribed then no actor is created from the generic_device class. At the moment it is just if a specific message is received then the actor is created. All help appreciated thanks. import logging from datetime import timedelta import time from thespian.actors import * from transitions import Machine import paho.mqtt.client as mqtt class laser

With the clear session flag set to FALSE, I am missing the published values

感情迁移 提交于 2019-12-01 12:10:42
问题 Is anyone has a logical explanation why despite I have the clear session flage = false I do not receive the updated published message I am subscribed to while i am not connected to the broker? With the aorementioned flag set to false I ran my App, And i kept publishing to a topic some values (from the PC to the broker not from the Android device to the broker). And then I unpluged the usb of the Android Device frm the pc, and kept publishing some values again. When I plugged the usb to the pc

Spring MqttPahoMessageDrivenChannelAdapter Lost connection:Connection lost; retrying

亡梦爱人 提交于 2019-12-01 11:42:27
问题 We are using Spring message-driven-channel-adapter to subscribe MQTT topic. But we are getting below error very frequently. I have tested connection using JavaScript client(mqttws31.js), which is working fine. Means there is no issue with connection. Error :- org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter connectionLost SEVERE: Lost connection:Connection lost; retrying... MQTT message :- [payload=6483D03E4C75BA943148F18D73,1.00,1E, headers={mqtt_retained

Send many publish message: Too many publishes in progress Error

烂漫一生 提交于 2019-12-01 11:00:27
Here is paho Async client: client = new MqttAsyncClient(appProps.getProperty("mqtt.broker"), appProps.getProperty("mqtt.clientId"), new MemoryPersistence()); client.setCallback(this); client.connect(null, new IMqttActionListener() { @Override public void onSuccess(IMqttToken imt) { try { client.subscribe(Constants.internalTopics, Constants.internalTopicQOS); } catch (MqttException ex) { ex.printStackTrace(); } } @Override public void onFailure(IMqttToken imt, Throwable thrwbl) { thrwbl.printStackTrace(); } }); Here I am sending messages in loop: while (iterator.hasNext()) { try { client

how to use ssl/tls in paho mqtt using python i got certificate verify failed

半世苍凉 提交于 2019-12-01 08:42:32
问题 hi I am working on IOT internet of things I am using paho MQTT I need to use SSL I wrote publish code using python I got an error in "certificate verify failed" please help me thank in advance MY PUBLISHING CODE import time import paho.mqtt.client as paho import ssl import certifi #define callback def on_message(client, userdata, message): time.sleep(1) print("received message =",str(message.payload.decode("utf-8"))) client= paho.Client("client-001") client.on_message=on_message print(

Processing a received message using paho mqtt in python

时间秒杀一切 提交于 2019-12-01 06:47:42
问题 import paho.mqtt.client as mqtt def on_connect(client, userdata, flags, rc): print("Connected with result code "+str(rc)) client.subscribe("/leds/pi") def on_message(client, userdata, msg): if msg.topic == '/leds/pi': print(msg.topic+" "+str(msg.payload)) client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message client.connect("localhost", 1883, 60) client.loop_start() I use this basic code to subscribe to a topic and receive a message. The on_message function gets

How to use a self signed certificate to connect to a Mqtt server in Android (paho client)?

跟風遠走 提交于 2019-12-01 02:00:59
Im having problem connecting to a mqtt server using self signed certificate. im using Paho client and want to connect to a server using a TLSv1.2 . actually i was successful to connect in Android APIs 20+ but no success for below this version. what ive done till now : 1- created a PKCS#12 keystore and put the .crt file and assing a password to it and save it (it will be a .pfx file) 2- added the .pfx file to raw folder of recourse in android project 3- used below code to load self signed certificate: connection = createConnection(mqttCallback); MqttConnectOptions connOpts = optionsFromModel

python mqtt script on raspberry pi to send and receive messages

∥☆過路亽.° 提交于 2019-11-30 13:31:19
问题 MQTT question: Hi, I’m trying to set up a MQTT network between multiple Raspberry Pis (starting with two). I have one raspberry pi (RPi-A), MQTT client, with a thermistor sensor attached and one raspberry (RPi-B), MQTT broker/client, acting as a hub for my network. Through python scripting I’d like the temperature to be sent every 30mins from RPi-A via MQTT to topic sensor/data and received by RPi-B. When RPi-B receives a message from RPi-A via topic sensor/data, I want it to respond with an