Skip to content

Commit 6a960f3

Browse files
authored
Correct local MQTT broker max connections param (#146)
* Correct local MQTT broker max connections param Snake case aMQTT broker max conections parameter to match v0.11.3. Ref - https://amqtt.readthedocs.io/en/v0.11.3/references/broker_config/ * Further fixes * Update to be Python 3.10+ compatible Asyncio usage pattern has changed
1 parent 2dbac72 commit 6a960f3

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

localhost-mqtt-broker/localhost_mqtt_broker.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,45 @@
3636
"default": {
3737
"type": "tcp",
3838
"bind": f"{args.host}:1883",
39-
"max-connections": 1000,
39+
"max_connections": 1000,
4040
},
4141
"tls": {
4242
"type": "tcp",
4343
"bind": f"{args.host}:8883",
44-
"max-connections": 1000,
45-
"ssl": "on",
44+
"max_connections": 1000,
45+
"ssl": True,
4646
"cafile": args.root_ca_cert_path,
4747
"certfile": args.server_cert_path,
4848
"keyfile": args.server_priv_key_path,
4949
},
5050
},
51-
"sys_interval": 10,
52-
"auth": {
53-
"allow-anonymous": True,
54-
"password-file": os.path.join(
55-
os.path.dirname(os.path.realpath(__file__)), "passwd"
56-
),
57-
"plugins": ["auth_anonymous"],
58-
},
59-
"topic-check": {
60-
"enabled": True,
61-
"plugins": []
51+
"timeout_disconnect_delay": 0,
52+
"plugins": {
53+
"amqtt.plugins.logging_amqtt.EventLoggerPlugin": {},
54+
"amqtt.plugins.logging_amqtt.PacketLoggerPlugin": {},
55+
"amqtt.plugins.authentication.AnonymousAuthPlugin": {
56+
"allow_anonymous": True
57+
},
58+
"amqtt.plugins.authentication.FileAuthPlugin": {
59+
"password_file": os.path.join(
60+
os.path.dirname(os.path.realpath(__file__)), "passwd"
61+
)
62+
},
63+
"amqtt.plugins.sys.broker.BrokerSysPlugin": {
64+
"sys_interval": 10
65+
},
6266
},
6367
}
6468

65-
broker = Broker(config)
66-
6769
async def broker_coroutine():
70+
broker = Broker(config)
6871
await broker.start()
72+
# Keep the broker running indefinitely
73+
await asyncio.Event().wait()
6974

7075
if __name__ == "__main__":
7176
formatter = "[%(asctime)s] :: %(levelname)s :: %(name)s :: %(message)s"
7277
logging.basicConfig(level=logging.DEBUG, format=formatter)
7378

7479
# Start the MQTT broker
75-
asyncio.get_event_loop().run_until_complete(broker_coroutine())
76-
asyncio.get_event_loop().run_forever()
80+
asyncio.run(broker_coroutine())

0 commit comments

Comments
 (0)