{"result":{"depiction_url":null,"edges":{"subject":{"objects":[{"created":"2026-09-30T09:11:22Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2673,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_javascript","title":"JavaScript","uri":"https:\/\/zotonic.com\/id\/2673"},"seq":3},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2677,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_mqtt","title":"MQTT","uri":"https:\/\/zotonic.com\/id\/2677"},"seq":4},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2717,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_message_bridge","title":"Message bridge","uri":"https:\/\/zotonic.com\/id\/2717"},"seq":5},{"created":"2026-09-30T09:11:22Z","object_id":{"id":2718,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_cotonic","title":"Cotonic","uri":"https:\/\/zotonic.com\/id\/2718"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":2729,"is_a":["text","documentation","reference","cotonic_reference"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2729"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_cotonic_cotonic_mqtt_bridge","page_url":{"en":"https:\/\/zotonic.com\/cotonic\/cotonic_mqtt_bridge","x-default":"https:\/\/zotonic.com\/cotonic\/cotonic_mqtt_bridge"},"preview_url":null,"resource":{"version":16,"pivot_location_lat":null,"title":"cotonic.mqtt_bridge","is_authoritative":true,"body":"<a name=\"cotonic.mqtt_bridge\"><\/a>\n\n            <p>\n            This module makes it possible to bridge the broker on the local page to\n            an external MQTT broker.\n            <\/p>\n\n            <a name=\"cotonic.mqtt_bridge.newBridge\"><\/a><h2>newBridge <code>cotonic.mqtt_bridge.newBridge([remote], [options])<\/code><\/h2><p>\n            Create a new bridge. This is the hostname of the mqtt broker to connect to. When set to\n            <tt>&quot;origin&quot;<\/tt> the bridge uses the hostname of the document.\n            When the bridge is connected messages published on the topic matching <tt>bridge\/+remote\/#<\/tt> will\n            be re-published on the remote broker. Subscriptions on the topic <tt>bridge\/+remote\/#<\/tt>\n            will be published locally. This makes it possible to connect and communicate with\n            all clients connected to remote mqtt brokers.\n            <em>Note: It is possible to connect to multiple brokers.<\/em>\n            <\/p>\n            <dl>\n                <dt><tt>protocol<\/tt><\/dt>\n                <dd>The protocol to use to connect to the mqtt broker. Defaults to &quot;ws&quot; when the page is\n                loaded via &quot;http&quot;, &quot;wss&quot; otherwise.\n                <\/dd>\n\n                <dt><tt>controller_path<\/tt><\/dt>\n                <dd>The pathname to use when connecting the web socket to the broker. Default: &quot;mqtt-transport&quot;<\/dd>\n\n                <dt><tt>connect_delay<\/tt><\/dt>\n                <dd>Default: 20<\/dd>\n\n                <dt><tt>periodic_delay<\/tt><\/dt>\n                <dd>Default: 1000<\/dd>\n\n                <dt><tt>username<\/tt><\/dt>\n                <dd>Default: undefined<\/dd>\n\n                <dt><tt>password<\/tt><\/dt>\n                <dd>Default: undefined<\/dd>\n\n                <dt><tt>mqtt_session<\/tt><\/dt>\n                <dd>The mqtt_session module which should be used. Default: cotonic.mqtt_session.<\/dd>\n            <\/dl>\n\n            <pre>\ncotonic.mqtt_bridge.newBridge(&quot;test.mosquitto.org:8081&quot;,\n                              {protocol: &quot;wss&quot;});\n=&gt; Connect the local broker to test.mosquitto.org via a websocket.\n\nconst decoder = new TextDecoder(&quot;utf-8&quot;);\ncotonic.broker.subscribe(&quot;bridge\/test.mosquitto.org:8081\/bbc\/subtitles\/bbc_news24\/raw&quot;,\n    function(m, t) {\n        console.log(decoder.decode(m.payload));\n    });\n=&gt; Subscribe to a local topic, it will be bridged from the server\n   to the page. This gets the raw subtitles of bbc news24.<\/pre>\n\n            <p>For windows opened by a window with a cotonic broker, a special bridge <tt>&quot;opener&quot;<\/tt> can\n                be started with <code>cotonic.mqtt_bridge.newBridge(&quot;opener&quot;);<\/code>. This bridge is a\n                simple one-way bridge that makes it possible for the opened window to publish to topics\n                in the opening window. It is not (yet) possible to subscribe to topics in the opener window.\n            <\/p>\n            <p>\n                Example publishing to the opener:\n            <\/p>\n\n            <pre>cotonic.broker.publish(&quot;bridge\/opener\/model\/sessionStorage\/post\/test&quot;, &quot;Hello&quot;);<\/pre>\n\n            <a name=\"cotonic.mqtt_bridge.findBridge\"><\/a><h2>findBridge <code>cotonic.mqtt_bridge.findBridge([remote])<\/code><\/h2><p>\n            Find bridge <tt>remote<\/tt>, when remote is not specified, <tt>&quot;origin&quot;<\/tt> is used.\n            Returns the bridge, or <tt>undefined<\/tt> when the bridge is not found.\n            <\/p>\n            <pre>\nconst b = cotonic.mqtt_bridge.findBridge(&quot;test.mosquitto.org:8081&quot;);\n=&gt; returns the bridge, or undefined\n            <\/pre>\n\n            <a name=\"cotonic.mqtt_bridge.deleteBridge\"><\/a><h2>deleteBridge <code>cotonic.mqtt_bridge.deleteBridge([remote])<\/code><\/h2><p>\n            Delete bridge <tt>remote<\/tt>, when remote is not specified, <tt>&quot;origin&quot;<\/tt> is used.\n            <\/p>\n            <pre>\ncotonic.mqtt_bridge.deleteBridge(&quot;test.mosquitto.org:8081&quot;);<\/pre>\n\n            \n\n\n            <!-- User interface composer -->\n\n            ","slug":"cotonic.mqtt_bridge","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"56e70f91e76c431767dde2cf362962bde33d4912abb1a2a15bf510e21418226c","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":2722,"is_a":["meta","category"],"name":"cotonic_reference","title":"Cotonic","uri":"https:\/\/zotonic.com\/id\/cotonic_reference"},"doc_source_path":"index.html","publication_start":"2026-09-30T09:11:22Z","page_path":"\/cotonic\/cotonic_mqtt_bridge","github_url":"https:\/\/github.com\/cotonic\/cotonic\/blob\/master\/index.html","pivot_location_lng":null,"doc_source_kind":"cotonic","name":"doc_cotonic_cotonic_mqtt_bridge","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2026-09-30T09:11:22Z","uri":null,"doc_source_anchor":"cotonic.mqtt_bridge","doc_status":"current","is_dependent":false,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"f88cc928b997d10f7f19e6bd0ede80e1c8c619bc","creator_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"modified":"2026-09-30T10:06:59Z","title_slug":"cotonic.mqtt_bridge"},"uri":"https:\/\/zotonic.com\/id\/2729","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2729"}},"status":"ok"}