Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The broker example code can't executed successfully using master branch. #118

Open
zhonhel opened this issue Jul 30, 2022 · 1 comment
Open

Comments

@zhonhel
Copy link

zhonhel commented Jul 30, 2022

I cloned the master branch code, and cd to the code dir.
Then I executed the following code which copyed from https://amqtt.readthedocs.io/en/latest/references/broker.html and putted them into simple_broker.py

import logging
import asyncio
import os
from amqtt.broker import Broker


async def broker_coro():
    broker = Broker()
    await broker.start()


if __name__ == '__main__':
    formatter = "[%(asctime)s] :: %(levelname)s :: %(name)s :: %(message)s"
    logging.basicConfig(level=logging.INFO, format=formatter)
    asyncio.get_event_loop().run_until_complete(broker_coro())
    asyncio.get_event_loop().run_forever()

Then I got the following error:

(mqtt-server) wrp@ecs-2:~/amqtt$ python simple_broker.py 
Traceback (most recent call last):
  File "/home/wrp/amqtt/amqtt/broker.py", line 201, in _build_listeners_config
    listeners_config = broker_config["listeners"]
KeyError: 'listeners'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/wrp/amqtt/simple_broker.py", line 15, in <module>
    asyncio.get_event_loop().run_until_complete(broker_coro())
  File "/home/wrp/Python-3.9.13_install/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/home/wrp/amqtt/simple_broker.py", line 8, in broker_coro
    broker = Broker()
  File "/home/wrp/amqtt/amqtt/broker.py", line 173, in __init__
    self._build_listeners_config(self.config)
  File "/home/wrp/amqtt/amqtt/broker.py", line 208, in _build_listeners_config
    raise BrokerException("Listener config not found invalid: %s" % ke)
amqtt.broker.BrokerException: Listener config not found invalid: 'listeners'
(mqtt-server) wrp@ecs-2:~/amqtt$ 

@not-f-elsner
Copy link
Collaborator

not-f-elsner commented Feb 7, 2023

Mh, I'm not sure if we should include a default listeners config in the broker, or if we should adapt the examples to provide such config

    "listeners":{
        "default":{
        "type": "tcp",
        "bind": "0.0.0.0:1883"
        } 
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants