Connection and credential options.
The live session.
import { connect } from 'edgeport/mqtt';
await using mqtt = await connect({ hostname: 'broker.example.com', username: 'u', password: 'p' });
await using sub = mqtt.subscribe('sensors/+/temp', { qos: 1 });
await mqtt.publish('sensors/1/temp', '21.5', { qos: 1 });
for await (const msg of sub) {
console.log(msg.topic, new TextDecoder().decode(msg.payload));
break;
}
Connects to an MQTT broker over TCP, performs the handshake, and returns a live session.
Dials the core transport (implicit TLS when
tls: 'implicit', a STARTTLS-style upgrade whentls: 'starttls', otherwise plaintext), sends CONNECT, and waits for CONNACK so an auth failure surfaces here. Whentransport: 'ws'is set, this delegates to connectWebSocket usingopts.url. A background pump then routes inbound messages to subscriptions.