MQTT

The MQTT connector subscribes to a broker on your network and turns every topic it hears into a source. Nothing opens inbound: the gateway dials the broker.

What to type

Open the gateway page, choose Add connector, pick MQTT, then fill in the Settings form on its tab and press Save. The connector stays idle and shows Needs settings until you do.

Host is the broker's name or address. Port defaults to 1883, or 8883 with TLS on. Username and Password are optional, a Password needs a Username, and a saved password is never shown again. Press Clear beside it to remove it.

Protocol offers auto, 5 and 3.1.1, and defaults to auto. Auto tries MQTT 5 and falls back to 3.1.1 when the broker refuses it. The tab shows the version in use. Pick 5 or 3.1.1 to skip the probe.

Client ID is optional. It defaults to foxtether- followed by 12 characters of the gateway id. Your own may be 1 to 23 letters, digits, - or _. Letters and digits alone are safest, since some brokers refuse anything else. Brokers drop an older session that shares a client id, so give each gateway its own.

Topic filters choose what the gateway subscribes to, from 1 to 16 of them, using the standard + and # wildcards. The default is #, which is everything the broker will deliver to this login. A shared subscription is written $share/group/filter.

TLS and certificates

Turn TLS on to dial over an encrypted connection. The gateway trusts the public certificate authorities built into it, plus the CA certificate you paste in. It never reads the operating system's certificate store.

A broker with its own CA needs that CA certificate in PEM form. A broker that asks for a client certificate needs the certificate and its key, both in PEM form, and one without the other is refused. A saved client key is never shown again and has its own Clear.

The broker's certificate must name the host you typed. A self-signed certificate on a bare IP address without an IP name in it fails the check, so use a host name or reissue the certificate. When the check fails the tab shows Broker certificate not trusted.

What a source is

Every concrete topic the gateway receives a message on becomes one source, named by the topic. A topic's first message registers it. Nothing is created ahead of time, so a new topic shows up the moment it publishes.

The source id comes from the gateway and the topic, so the same topic on two gateways is two sources. Moving the broker to a new address keeps every id.

The payload is carried byte for byte. FoxTether does not decode it, so JSON, a binary frame and a Sparkplug B message all pass through as they arrived. Retain, QoS and duplicate flags are not carried. Retained messages that the broker sends on subscribe are forwarded like any other.

A topic that goes quiet stays a source. It reads Idle after 30 seconds without a message and Stale after 300 seconds. A topic leaves only when you change the filters so they no longer match it, when you stop the connector, or when you remove it.

The tab shows sources as a tree, split at each /. A branch rolls up how many of the sources under it are live, idle and stale.

Sending a topic onward

A branch of the tree has Route to egress. It lets you pick an existing egress or start a new one and opens its Scope tab with a Name starts with rule filled in for that branch. Saving the rule is your click.

A webhook egress receives the topic in the x-foxtether-source-name header, percent-encoded. The header is described in the webhook docs.

Limits

Messages up to 8 MiB are carried. Under MQTT 5 the gateway tells the broker this limit, and the broker discards a larger message before it reaches the gateway, so nothing is counted or shown. If the broker instead closes the session over a packet it finds too large, the tab shows Message too large. Under MQTT 3.1.1 the gateway drops a message over 8 MiB, counts it, and shows Message too large on the tab. A message more than twice the limit also drops the connection, and the gateway reconnects.

A topic name longer than 1 KiB is dropped at the gateway and counted as too large.

A gateway tracks at most 10,000 topics. Past that the tab reads Source limit reached, a new topic is dropped at the gateway and counted, and it reaches no egress. The sources you already have keep flowing, and a topic leaves when a filter change stops matching it, which clears the notice.

A workspace holds up to 10,000 sources across all its gateways. The tab shows how close you are once you pass 90 percent. A topic past that limit that a gateway still tracks keeps reaching an egress scoped to that gateway or to all gateways. It cannot match a Name starts with rule and does not show in the portal until the workspace is under the limit.

Each topic has a mailbox of 64 messages. When a source cannot keep up, the gateway drops messages for that topic and the source reports the drops. It never stalls the broker connection.

The session is clean. A message published while the gateway is disconnected is lost, and nothing is replayed after a reconnect apart from the broker's retained messages. A broker restart resubscribes on its own and keeps the same ids.

Timed publishes

Some brokers and devices only publish after a client asks. A timed publish makes the gateway send one message to your broker on a schedule. It is off until you add one, and the tab shows Sends to broker while any exist.

Each entry has a topic, a payload that may be empty, and an interval of 5 to 3,600 seconds. A payload is at most 64 KiB. You can add up to 8. They are sent at QoS 1 and not retained. Each one is sent once right after every connect, then on its interval while the session is up. A new or changed entry is sent as soon as you save it, and the others keep their schedule.

Your broker's own access rules decide whether the gateway may publish. Under MQTT 5 a refusal shows as Broker refused a publish until that publish next succeeds. The same notice shows when a payload is larger than the broker accepts, and the gateway then does not send it. Under MQTT 3.1.1 the broker gives no answer, so a refused publish is not visible anywhere.

A timed publish can come back to the gateway as a source when one of your filters matches its topic. MQTT 5 does not send it back through an ordinary filter, but MQTT 3.1.1 and any $share/ filter can. Keep timed publish topics outside your filters, and always outside a $share/ filter.

Anyone who can edit the gateway can add a timed publish. Each change is recorded under Settings, Security.

Reading the status

Connecting: the gateway is dialing or backing off. Retries start at 1 second and double up to 60 seconds.

Can't reach the broker: the address did not answer. Check the host, the port and that the gateway can route to it.

Broker refused the login: the username, password or client certificate was not accepted, or this login may not connect.

Broker refused the Client ID: the broker does not accept the Client ID. Leave it empty to use the default, or use letters and digits only.

Client ID in use: the broker closed the session because another client connected with the same Client ID. Give each gateway its own.

Broker denied access: the broker closed the session because this login is not allowed to do something it asked for, such as a timed publish. Check the broker's access rules.

Client ID in use, Broker denied access and Message too large stay on the tab while the gateway reconnects, and clear once a session lasts 30 seconds.

Broker refused a filter: the broker would not let this login subscribe to one of your filters. It clears when that filter next subscribes, or when you remove it.

Settings the gateway cannot use, such as a malformed certificate, show as the connector's Down reason with the offending field named.

Two gateways on one broker

Each gateway gets its own sources, so two gateways never merge or fight over one. To split the work, give each gateway its own filters, for example site/plant1/# on one and site/plant2/# on the other.

When you save filters that overlap another gateway on the same broker, the tab says which, for example: site/# overlaps Plant 2 (site/plant2/#). Both will collect those topics. It is a warning and never blocks Save, since collecting a topic twice can be deliberate.