aedes | Barebone MQTT broker that can run on any stream server | Websocket library
kandi X-RAY | aedes Summary
kandi X-RAY | aedes Summary
Barebone MQTT broker that can run on any stream server, the node way
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Pushes a message to the queue .
aedes Key Features
aedes Examples and Code Snippets
var aedes = require('aedes')
var stats = require('aedes-stats')
var instance = aedes()
stats(instance)
const aedes = require('aedes')()
const server = require('net').createServer(aedes.handle)
const httpServer = require('http').createServer()
const ws = require('websocket-stream')
const port = 1883
const wsPort = 8883
server.listen(port,
const aedes = require('aedes')();
const server = require('net').createServer(aedes.handle);
const port = 1883;
// exports.startBroker = function() {
const startBroker = function() {
return new Promise((res, rej) => {
server
Community Discussions
Trending Discussions on aedes
QUESTION
I would like to connect a test MQTT-Client to my Node.js application as a MQTT-Broker. I am using the aedes library from moscajs
My MQTT-Client is the tool "MQTT-Explorer" and here is my Node.js application:
...ANSWER
Answered 2022-Mar-01 at 20:20MQTT Explorer is built using Node.js and the MQTT library MQTT.js. As per this issue:
Node.js requires the IP address to be in the subjectAltNames for the cert and not in the CN. Maybe MQTT.fx isn't requiring that, but it should.
and:
If your server's certificate says CN=localhost in the Subject field, connect using localhost and not 127.0.0.1 and it should work. If it says CN=127.0.0.1, you have to make a new one because Node.js won't validate the IP address unless it's in the SAN extension. There is a way to work around it in code (I think it's an option called checkServerIdentity), but I would prefer to fix my certificate if I had this problem.
A rationale for the approach taken in Node is set out in this answer which includes the following quote from RFC2818: HTTP Over TLS :
In some cases, the URI is specified as an IP address rather than a hostname. In this case, the iPAddress subjectAltName must be present in the certificate and must exactly match the IP in the URI.
As you are using MQTT over TLS (as opposed to HTTP Over TLS) you could argue that the above does not apply but, given that the main use of the TLS library is for HTTP traffic, it makes sense that it confirms to the RFC by default.
You have a few options including:
- Use a hostname (e.g.
localhost
) rather then an IP when creating the certificate/connecting. - Add the IP as a subjectAltName
- Modify the library to use a noop
checkServerIdentity
(see this answer). - Use another application for testing (not really recommended as some applications will work and others will not). The issue quoted above mentions that MQTT.fx works.
QUESTION
I am working on a project to have a random word guessing game. So far most of the code is working but I am trying to implement some rules on the length of words displayed to the user as a measure of game difficulty (shorter words = easier, etc). I am using a drop-down menu to get the user's setting selection, and then have rules in the JS tags that are supposed to be handling this.
After toying around with this for several days, I was hoping that a fresh pair of eyes might have a suggestion about where I am going wrong to be able to enforce the rules I am trying to enforce?
The specific functions that should be handling this are setDifficulty(), getSelection(), and randomWord()
ANSWER
Answered 2021-Dec-02 at 00:06Let's start by saving the difficulty setting in a variable along these :
QUESTION
I have a Node JS MQTT server running on websockets and deployed to Cloud Run. This server uses Aedes MQTT Broker library (https://github.com/moscajs/aedes). Clients connect to this server on port 443. Everything works ok, but periodically each client is disconnected from the MQTT Broker (aprox. every 5 minutes since each client first connected) This does not happen when the server is deployed to a dedicated machine or a Google Cloud VM, only happens when deployed to Google Cloud Run.
To illustrate the problem, I have written in NodeJS a super simple MQTT server, which allows any client to connect and echoes to queue "responses" any message that the client sends to queue "messages" and a NodeJS script to test it. You may find the full 2-files project in https://github.com/madomingo/mqtt_test/tree/main
The server code is:
...ANSWER
Answered 2021-Sep-17 at 08:02As per the comments the docs say:
WebSockets requests are treated as long-running HTTP requests in Cloud Run. They are subject to request timeouts (currently up to 60 minutes and defaults to 5 minutes) even if your application server does not enforce any timeouts.
Accordingly, if the client keeps the connection open longer than the required timeout configured for the Cloud Run service, the client will be disconnected when the request times out.
Therefore, WebSockets clients connecting to Cloud Run should handle reconnecting to the server if the request times out or the server disconnects. You can achieve this in browser-based clients by using libraries such as reconnecting-websocket or by handling "disconnect" events if you are using the SocketIO library.
This will apply to MQTT over WebSockets so changing the timeout will allow longer connections but you should also ensure that the client is automatically reconnecting when the connection does go down.
QUESTION
I am new to MQTT. Is it possible to have an external IOT device that can publish it's readings in MQTT format and use the aedes MQTT broker node and a subscriber node in node-red that is installed in the IBM cloud environment to receive the payloads?
Currently I have a simple setup within node-red with the publish and subscribe nodes when using the 'localhost:1883' as a server address. Do I need to have a server with IP address to make this work?
Where do I start?
...ANSWER
Answered 2021-Sep-02 at 07:56Short answer, no.
You can only access Node-RED running on IBM Cloud via HTTP/HTTPS, you will not be able to connect to the any broker you ran in the Node-RED process externally.
This is because the Node-RED instance is behind a reverse HTTP/HTTPS proxy.
You could deploy Node-RED in a Docker container or on a Virtual machine, or just make use of an external MQTT broker. But without a much better understanding of the whole problem you are trying to solve it is impossible to be more specific.
QUESTION
I have an abundance dataframe improved as a csv with column and row headers. When imported, and running str(data)
it shows each row as int. I can't use vegan's package specaccum
unless the data is numeric. After converting my dataframe into numeric it is still producing the following error:
ANSWER
Answered 2021-Aug-10 at 18:47According to ?specaccum
permutations - Number of permutations with method = "random". Usually an integer giving the number permutations, but can also be a list of control values for the permutations as returned by the function how, or a permutation matrix where each row gives the permuted indices.
QUESTION
The main stuff
I receive an MQTT packet (which appears as an ASCII array to the buffer in format [after being printed using stringify]):
...ANSWER
Answered 2021-Aug-02 at 20:19The following code will take the array and convert it back to a string via a buffer.
QUESTION
I can create an MQTT broker. I can create a web client also. but there is a problem with the device. I try to connect with the IP(ws://192.168.1.240:1883) of the device. The device could not connect to the broker. Web client could connect with WebSocket.
...ANSWER
Answered 2020-Dec-09 at 08:00If you want to use both MQTT over Websockets and native MQTT you will need to configure the broker to listen on 2 separate ports. You can't listen for both on the same port.
e.g. This will accept native MQTT connections on 1883 and Websocket connections on 8883
QUESTION
I am using an Aedes as the broker and MQTT.js as a client in a web application.
At startup I connect to the broker and subscribe to some channels.
I would like to know if there's a way to get the last previous messages in a MQTT way.
...ANSWER
Answered 2020-Oct-28 at 15:22There are 2 different things here.
Retained messages. This is a flag set on the message by the publisher, it tells the broker to hold on to the message and always deliver the last retained message on any given topic to a client when they first subscribe to that topic before any new messages are sent. The last retained message will always be replaced by the next message published on that topic that also has the retained flag set. You can read more about retained messages here
Queued messages. If the client subscribes to a topic at greater than QOS 0 then the broker will queue up messages sent for that client while it is offline. The client needs to reconnect using the same client ID and with the
cleanSession
flag set to false. You can read more about persistent sessions and queued messages here
QUESTION
I'm making an app to manage some smart lights in my house.
I've created a really simple Broker
class.
ANSWER
Answered 2020-Oct-16 at 06:35You have to bind the this
context of the class instance to a method if you'd like to pass that method as a callback. There are a couple of ways to do this in TypeScript.
Defining the method using an arrow function:
QUESTION
I am using google spreadsheets.
Imagine there are some families of insects with the following names in column A, and their genera in column B and C imaginary names for species (they are unique FOR each genus).
What I need is to have for EACH FAMILY (column A) the UNIQUE number of genus. I'll give the desired result after this table 1.
NOTE: Culicidae has 31 rows
Table 1- Original table
...ANSWER
Answered 2020-Jul-06 at 21:09While it might not be achieved in a formula, utilizing the Pivot Table function will result in the second table that you are looking for, as well as being dynamic.
In Google sheets, select your data range (Table 1) -> Click on the Data
-> Select Pivot Table
. From there confirm that the data range is correct and that New sheet is selected. Click create and you should be moved to the new sheet with the Pivot table editor pane open.
To get the desired output as Table 2 add Family
to Rows and Genera
to Values. By default Genera will be summarized by COUNTA; in order to get the UNIQUE Count all you need to do is change COUNTA to COUNTUNIQUE.
This Table will update automatically to any changes made within the original range, however make sure that if you add/remove any new rows that you update the Data Range within the Pivot table editor.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aedes
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page