Skip to content

Commit

Permalink
Added try to convert RPC response to json from string, before sending…
Browse files Browse the repository at this point in the history
… it to server, to avoid issues with remote shell
  • Loading branch information
imbeacon committed Dec 2, 2024
1 parent 9c6f7a2 commit 1ee1302
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion thingsboard_gateway/gateway/tb_gateway_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,11 @@ def __send_rpc_reply(self, device=None, req_id=None, content=None, success_sent=
if success_sent is not None:
if success_sent:
rpc_response["success"] = True
if isinstance(content, str):
try:
content = loads(content)
except Exception:
content = {"response": content}
if device is not None and success_sent is not None and not to_connector_rpc:
self.tb_client.client.gw_send_rpc_reply(device, req_id, dumps(rpc_response),
quality_of_service=quality_of_service)
Expand All @@ -1706,7 +1711,7 @@ def __send_rpc_reply(self, device=None, req_id=None, content=None, success_sent=
wait_for_publish=wait_for_publish)
self.__rpc_reply_sent = False
except Exception as e:
log.exception(e)
log.exception("Error while sending RPC reply", exc_info=e)

def register_rpc_request_timeout(self, content, timeout, topic, cancel_method):
# Put request in outgoing RPC queue. It will be eventually dispatched.
Expand Down

0 comments on commit 1ee1302

Please sign in to comment.