2022. 11. 15. 01:52ㆍ서버 프로그래밍
Mosquitto와 같은 MQTT 브로커에 연결시 keep-alive-time out이 발생할 수 있다.
Subscribe하는 태스크는 loop 함수를 사용해서 연결을 계속 유지하면서 메시지 수신하도록 처리해야 하고, Publish를 담당하는 태스트는 Publish할 때만 연결을 했다가 Publish 후에는 연결을 끊어줄 필요가 있다.
Publish 태스크까지 굳이 계속 연결을 유지할 필요가 없다.
http://www.steves-internet-guide.com/connected-or-disconnect/
MQTT Connections - Should You Stay Connected
Do you close an MQTT connection after sending data or do you disconnect? In this article I discuss the pros and cons of staying connected and the things you must consider. I also invite feedback
www.steves-internet-guide.com
http://www.steves-internet-guide.com/mqtt-keep-alive-by-example/
MQTT Keep Alive Interval Explained With Examples
MQTT uses a keepalive mechanism for checking the status of the TCP/IP connection.On a quiet TCP/IP connection an MQTT client will send a PINGREQ at set intervals and expect to receive a PINGRESP.
www.steves-internet-guide.com