thingsboard网关使用mqtt连接器发送双向RPC时,总是收不到响应,看了一下网关日志,报错了。。

    1. Exception in thread Thread-6:
    2. Traceback (most recent call last):
    3. File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    4. self.run()
    5. File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
    6. self._target(*self._args, **self._kwargs)
    7. File "/Library/Python/3.7/site-packages/paho/mqtt/client.py", line 3452, in _thread_main
    8. self.loop_forever(retry_first_connection=True)
    9. File "/Library/Python/3.7/site-packages/paho/mqtt/client.py", line 1779, in loop_forever
    10. rc = self.loop(timeout, max_packets)
    11. File "/Library/Python/3.7/site-packages/paho/mqtt/client.py", line 1181, in loop
    12. rc = self.loop_read(max_packets)
    13. File "/Library/Python/3.7/site-packages/paho/mqtt/client.py", line 1572, in loop_read
    14. rc = self._packet_read()
    15. File "/Library/Python/3.7/site-packages/paho/mqtt/client.py", line 2310, in _packet_read
    16. rc = self._packet_handle()
    17. File "/Library/Python/3.7/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle
    18. return self._handle_publish()
    19. File "/Library/Python/3.7/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish
    20. self._handle_on_message(message)
    21. File "/Library/Python/3.7/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_message
    22. self.on_message(self, self._userdata, message)
    23. File "/Users/weijixin/PycharmProjects/thingsboard-gateway/thingsboard_gateway/connectors/mqtt/mqtt_connector.py", line 505, in _on_message
    24. if message.topic in self.__gateway.rpc_requests_in_progress:
    25. AttributeError: 'TBGatewayService' object has no attribute 'rpc_requests_in_progress'

    经过反复验证,确实是个BUG。解决方案见另一篇文章 MQTT连接器案例及双向RPC的BUG修复