mqtt

MQTT in AWS Lambda function for Alexa Javascript

天涯浪子 提交于 2019-12-13 07:17:31
问题 Please help, I need to use mqtt protocol in lambda function to send some data to a broker. I use simple code to test it : mqtt = require('mqtt'); var client = mqtt.connect('mqtt://test.mosquitto.org'); client.on('connect', function () { client.subscribe('presence'); client.publish('presence', 'Hello mqtt'); }); client.on('message', function (topic, message) { // message is Buffer console.log(message.toString()); client.end(); }); But I get an error "Cannot find module 'mqtt'", how can I

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

Mosquitto sending messages to Azure IoTHub

末鹿安然 提交于 2019-12-13 06:53:41
问题 Azure has implemented MQTT protocol in its IoTHub so I'm trying to use mosquitto to send messages from my pc. I'm creating azure devices using Device Explorer. In the beginning I generated SAS token from there, but it hasn't the "&skn=" part, so I tried to generate a new SAS using compatible event hub from visual studio. After that i tried to use mosquitto broker to send an MQTT message to my IoTHub using parameters in the CONNECT packet as explained here: https://azure.microsoft.com/en-us

mqtt.js does not queue more than 65535 publish messages

扶醉桌前 提交于 2019-12-13 04:26:43
问题 I've been trying to use https://www.npmjs.com/package/mqtt to simulate a large number of publishes and found that the queue does not hold more than 65535 messages at a time. (If I try to send more, the remaining are discarded) Is there a reason for this and are there any workarounds? 回答1: Because that is the maximum number of packet ids allowed in the MQTT spec Packet ids are a 16bit number (max 65535) and must be unique for all inflight messages. SUBSCRIBE, UNSUBSCRIBE, and PUBLISH (in cases

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

MQTT Over Websockets in Android

怎甘沉沦 提交于 2019-12-13 02:59:49
问题 I am using Paho Android Service for MQTT over web sockets. https://www.hivemq.com/blog/mqtt-client-library-enyclopedia-paho-android-service My question is how do I set the Broker WSS URI which has a query parameter in it. For example: wss://test.amazon.com:80/mqtt?query1=value&query2=value Edit If we add the complete URL, the PAHO client library throws following exception: MqttException (0) - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String

(ERROR MODULE) python mqtt_Listen_Sensor_Data.py

Deadly 提交于 2019-12-13 02:51:17
问题 I'm trying to store my MQTT data in SQLITE database on raspberry. What am I doing wrong to get the error below? CODE: import paho.mqtt.client as mqtt from store_Sensor_Data_to_DB import sensor_Data_Handler # MQTT Settings MQTT_Broker = "tcp://localhost:1883" MQTT_Port = 1883 Keep_Alive_Interval = 45 MQTT_Topic = "kuca/primanje/kanta01/r" #Subscribe to all Sensors at Base Topic def on_connect(mosq, obj, rc): self.subscribe(MQTT_Topic, 0) #Save Data into DB Table def on_message(mosq, obj, msg):

Facing Error while using TLS with mosquitto

守給你的承諾、 提交于 2019-12-13 02:50:21
问题 I am trying to use TLS for communicating over mqtt. I have ubuntu installed in my system. For using TLS, I have created certificates using the below link: http://www.embedded101.com/Blogs/PaoloPatierno/entryid/366/mqtt-over-ssl-tls-with-the-m2mqtt-library-and-the-mosquitto-broker I am able to create certificates. But when I give value to bind_address property in the mosquitto_m2mqtt.conf file and start mosquitto using the command mosquitto -c mosquitto_m2mqtt.conf , I get error as given in

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"

Cannot Pub or Sub on AWS IoT using MQTT over Websockets

半腔热情 提交于 2019-12-13 01:09:25
问题 I can successfully connect to AWS IoT using MQTT over Websockets. But when publishing or subscribing, the connection is terminated. I figure it must be a policy/permissions-based issue with AWS, but I am confident that I have the correct permissions. Here is my setup: I have a lambda function which creates a signed url using STS assumeRole (permissions in policy will be tighter but I have allowed access to all iot functions on all resources for testing): const config = require('./config');