简体   繁体   中英

Python Tornado Backend, WebSocket Listener and MQTT Client at the same time

I wanted to ask you if it's possible to run a MQTT Client and Listen to WebSocket at the same time with the Python Backend Framework Tornado.

My goal is to create a MQTT Client which sends a WebSocket with the received Message from the MQTT Broker to a React frontend.

But my first step is to successfully run MQTT Client and WebSocket on the Backend.

Thank you in advance

I managed it with a new Thread

if __name__ == "__main__":

 thread = Thread(target = mqtt_set)
 thread.start()

 application = tornado.web.Application([
 (r"/websocket", EchoWebSocket),
 (r"/main", MainHandler),
 ])

 application.listen(8888)
 tornado.ioloop.IOLoop.instance().start()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM