mirror of
https://github.com/balkian/mqtt-poc.git
synced 2025-08-29 16:52:22 +00:00
First commit
This commit is contained in:
1
python-broker/Dockerfile
Normal file
1
python-broker/Dockerfile
Normal file
@@ -0,0 +1 @@
|
||||
FROM python:onbuild
|
46
python-broker/broker.py
Normal file
46
python-broker/broker.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import logging
|
||||
import asyncio
|
||||
import os
|
||||
from hbmqtt.broker import Broker
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
config = {
|
||||
'listeners': {
|
||||
'default': {
|
||||
'type': 'tcp',
|
||||
'bind': '0.0.0.0:1883',
|
||||
},
|
||||
'ws-mqtt': {
|
||||
'bind': '127.0.0.1:8080',
|
||||
'type': 'ws',
|
||||
'max_connections': 10,
|
||||
},
|
||||
},
|
||||
'sys_interval': 10,
|
||||
'auth': {
|
||||
'allow-anonymous': True,
|
||||
'password-file': os.path.join(os.path.dirname(os.path.realpath(__file__)), "passwd"),
|
||||
'plugins': [
|
||||
'auth_file', 'auth_anonymous'
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
broker = Broker(config)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_coro():
|
||||
yield from broker.start()
|
||||
#yield from asyncio.sleep(5)
|
||||
#yield from broker.shutdown()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
formatter = "[%(asctime)s] :: %(levelname)s :: %(name)s :: %(message)s"
|
||||
#formatter = "%(asctime)s :: %(levelname)s :: %(message)s"
|
||||
logging.basicConfig(level=logging.INFO, format=formatter)
|
||||
asyncio.get_event_loop().run_until_complete(test_coro())
|
||||
asyncio.get_event_loop().run_forever()
|
1
python-broker/passwd
Normal file
1
python-broker/passwd
Normal file
@@ -0,0 +1 @@
|
||||
test:$6$l4zQEHEcowc1Pnv4$HHrh8xnsZoLItQ8BmpFHM4r6q5UqK3DnXp2GaTm5zp5buQ7NheY3Xt9f6godVKbEtA.hOC7IEDwnok3pbAOip.
|
1
python-broker/requirements.txt
Normal file
1
python-broker/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
hbmqtt
|
Reference in New Issue
Block a user