mqtt

How to read data from MQTT in Eclipse Paho?

℡╲_俬逩灬. 提交于 2019-12-25 06:45:20
问题 I am trying to read sensor data using MQTT, using Eclipse Paho. I am successfully connected, but I want to read data. my code so far: public static void main(String[] args) { MqttClient client; MqttMessage msg; MemoryPersistence persistence; MqttConnectOptions conn; IMqttMessageListener listen; String broker = "tcp://url:1883"; String str = "password"; char[] accessKey = str.toCharArray(); String appEUI = "userID"; try { persistence = new MemoryPersistence(); client = new MqttClient(broker,

Why is this MQTT client example failing?

让人想犯罪 __ 提交于 2019-12-25 06:17:27
问题 I am trying out MQTT for the first time using Python and the mosquitto library. My client program is below. I'm trying to use the public demo MQTT server at http://www.mqtt-dashboard.com/subscribe. However the client code is failing, see error below. Any ideas on what's going on? #!/usr/bin/env python import mosquitto client = mosquitto.Mosquitto("fredtest", clean_session=True) client.connect("broker.mqttdashboard.com", 1883) client.publish("fred.test", "hello world", 1) client.loop_forever()

Can't connect to localhost Mosquitto Broker with Javascript?

拟墨画扇 提交于 2019-12-25 02:47:27
问题 I have a raspberry pi with a Mosquitto Broker running on it connected to a sensor module with MQTT Protocol inbuilt. If I use this code in terminal, I can subscribe and see my data coming back. mosquitto_sub -h 169.254.118.199 -t Advantech/00D0C9FA9984/data When using a websocket method in my HTML/Javascript I can't make a connection. I am not 100% sure what port I need to specify, I have seen most posts using port 1883 but this doesn't seem to work. In terminal there is no port required.

Sending BLE device data to server in background

跟風遠走 提交于 2019-12-25 02:00:31
问题 I develop an application that reading data from BLE device and send this data to MQTT broker (server). But when application entering to the background, data sending stopped after 3 minutes (I use Background Tasks). How I can increase this time. Or maybe there is an official mechanism, that Apple promotes and will not reject on the confirmation step on App Store, for reading data from BLE and sending this data to the server in the background that not limited by time? My Background Task:

Python Flask App with MQTT

*爱你&永不变心* 提交于 2019-12-24 19:33:39
问题 I'm trying to use my Flask app as a subscriber, but it does not call the on_message callback when receiving a message. Instead, I get about like the following: Connected with result code 0 Closing data file... Connected with result code 0 Closing data file... This is how I am running the Flask app: main.py: from flask import Flask, render_template, redirect, url_for from flask_bootstrap import Bootstrap from flask_nav import Nav from flask_nav.elements import * import paho.mqtt.client as mqtt

MQTT catch-up missed messages, looking for feedback on design/assumptions

与世无争的帅哥 提交于 2019-12-24 18:29:39
问题 I would like some feedback on this problem and my proposed solution to catching up after missed MQTT messages please: [Update 1] Simplified problem diagram and added solution diagram. Added mention of QoS Scenario: Client A publishes messages that we wish Client B to receive, even if connections are temporarily dropped then restored. Config Client A: connect with clean=false. Publish stateful messages with retain = true, non-stateful messages published with retain = false Client B: connect

Spring message-driven-channel-adapter: handling connection refused error

天大地大妈咪最大 提交于 2019-12-24 16:35:22
问题 I want to configure my message-driven-channel-adapter in such a way that I can grab the 'connection refused' error in case when: 1) the message broker is down or 2) A wrong broker URL is specified I tried doing this with the code below but it did not work: <int:channel id="invalidChannel" /> <int-mqtt:message-driven-channel-adapter id="myAdapter" client-id="${inbound.client.id}" url="${host.url}" topics="${inbound.topic}" channel="incomingChannel" error-channel="errorChannel" client-factory=

How to use MQTT on React Native?

北慕城南 提交于 2019-12-24 10:25:23
问题 I am pretty new at React Native, and I would like to use MQTT in my app. I trying to follow the instructions in the link --> https://github.com/Introvertuous/react_native_mqtt I installed MQTT throught the command --> npm install react_native_mqtt --save My question is: - Where should I paste the code below? In the app.js file? Do I need to create another file? - What should I write in the app.js file to test the MQTT connection? Any guidance it is welcome. import init from 'react_native_mqtt

Use MQTTNet Server with MQTT.js client

北慕城南 提交于 2019-12-24 09:39:47
问题 I have started an MQTT server just like this example. This code is hosted in an ASP.Net Core 2.0 application but I have tried console application with no luck. I have also setup a client using the same demo as above and it connects perfectly. Also an Android client connects fine. But I have placed a MQTT.js client webpage but it will not connect with chrome showing net::ERR_CONNECTION_REFUSED error. I believe that the problem is with server not supporting web sockets. Because if I start my

Keep MQTT Topics Subscribed onResume Activity

旧城冷巷雨未停 提交于 2019-12-24 08:11:51
问题 I've a MQTT Service Class, MyMqttService.class, runing when I log in in my app: Intent intent = new Intent(getApplicationContext(), MyMqttService.class); startService(intent); Then I have various Activities and in one of them, I have switch buttons to select which channels I want to subscribe. In my onPause/onResume, I check which buttons are on and which are off and make them go to that same state when I come back to that Activity. The problem is, if there is at least one button on when I