Add samples for SSL and WS

pull/8/head
Nicolas Jouanin 2015-08-06 21:08:22 +02:00
rodzic 901574f2da
commit 9428accbf7
3 zmienionych plików z 40 dodań i 10 usunięć

Wyświetl plik

@ -4,7 +4,36 @@ from hbmqtt.broker import Broker
logger = logging.getLogger(__name__)
broker = Broker()
config = {
'listeners': {
'default': {
'type': 'tcp'
},
'tcp-mqtt': {
'bind': '0.0.0.0:1883',
},
'ws-mqtt': {
'bind': '127.0.0.1:8080',
'type': 'ws'
},
'wss-mqtt': {
'bind': '127.0.0.1:8081',
'type': 'ws',
'ssl': 'on',
'certfile': 'localhost.server.crt',
'keyfile': 'server.key',
},
'tcp-ssl': {
'bind': '127.0.0.1:8883',
'ssl': 'on',
'certfile': 'localhost.server.crt',
'keyfile': 'server.key',
'type': 'tcp'
}
}
}
broker = Broker(config)
@asyncio.coroutine
def test_coro():

Wyświetl plik

@ -17,15 +17,15 @@ config = {
'topic': '/will/client',
'message': b'Dead or alive',
'qos': 0x01,
'retain': True
}
'retain': True,
},
}
#C = MQTTClient(config=config)
C = MQTTClient()
C = MQTTClient(config=config)
#C = MQTTClient()
@asyncio.coroutine
def test_coro():
yield from C.connect('mqtts://test.mosquitto.org:8883/', cafile='mosquitto.org.crt')
yield from C.connect('mqtts://test.mosquitto.org/', cafile='mosquitto.org.crt')
tasks = [
asyncio.async(C.publish('a/b', b'TEST MESSAGE WITH QOS_0')),
asyncio.async(C.publish('a/b', b'TEST MESSAGE WITH QOS_1', qos=0x01)),

Wyświetl plik

@ -18,14 +18,15 @@ config = {
'message': b'Dead or alive',
'qos': 0x01,
'retain': True
}
},
'capath': '.',
}
#C = MQTTClient(config=config)
C = MQTTClient()
C = MQTTClient(config=config)
#C = MQTTClient()
@asyncio.coroutine
def test_coro():
yield from C.connect('ws://test.mosquitto.org:8080/')
yield from C.connect('wss://test.mosquitto.org:8081/', cafile='mosquitto.org.crt')
tasks = [
asyncio.async(C.publish('a/b', b'TEST MESSAGE WITH QOS_0')),
asyncio.async(C.publish('a/b', b'TEST MESSAGE WITH QOS_1', qos=0x01)),