Closed misupopo closed 2 years ago
Hello misupopo,
You should be able to use the coreMQTT mutual authentication demo to test if your mqtt broker is working. Follow the demo setup guides, but when configuring the endpoint, use your URL.
https://docs.aws.amazon.com/freertos/latest/userguide/mqtt-demo-ma.html https://docs.aws.amazon.com/freertos/latest/userguide/freertos-getting-started-demo.html https://github.com/aws/amazon-freertos/blob/main/demos/coreMQTT/mqtt_demo_mutual_auth.c
Do you already have a device you intend to use for connection?
Thank you for your reply. I am using ESP32-devkitc.
The connection sample is as follows.
import * as mqtt from 'mqtt';
(async () => {
try {
const host = 'localhost';
const portNumber = 1883;
const username = 'admin';
const password = 'admin';
const connectUrl = `mqtt://${host}:${portNumber}/`
const client = await mqtt.connect(connectUrl,{
clean: true,
connectTimeout: 4000,
username,
password,
reconnectPeriod: 1000,
});
In that case, there's a Getting Started guide for the ESP32-DevKitC you can read through to get set up prior to running the demos. https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html
I'm going to close this issue - feel free to reopen it if you need anything else from us.
I set up a local mqtt server on my macbook. I built it with typescript and docker.
I want to connect to the URL "mqtt://localhost:1883" to receive topic messages.
Is there any sample code or demo code instead of coreMqtt documentation? I would appreciate it if someone teach me a more concrete sample of the connection, rather than a library.