Skip to content

Commit 031379e

Browse files
committed
Adjusted limitations processing on getting service configuration
1 parent 6a1c45c commit 031379e

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

tb_device_mqtt.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,12 +661,10 @@ def send_rpc_call(self, method, params, callback):
661661
self.__device_client_rpc_dict.update({self.__device_client_rpc_number: callback})
662662
rpc_request_id = self.__device_client_rpc_number
663663
payload = {"method": method, "params": params}
664-
self._publish_data(payload,
665-
RPC_REQUEST_TOPIC + str(rpc_request_id),
666-
self.quality_of_service)
664+
self._publish_data(payload, RPC_REQUEST_TOPIC + str(rpc_request_id), self.quality_of_service)
667665

668666
def request_service_configuration(self, callback):
669-
self.send_rpc_call("getSessionLimits", {}, callback)
667+
self.send_rpc_call("getSessionLimits", {"timeout": 5000}, callback)
670668

671669
def on_service_configuration(self, _, response, *args, **kwargs):
672670
if "error" in response:
@@ -688,7 +686,10 @@ def on_service_configuration(self, _, response, *args, **kwargs):
688686
if rate_limits_config.get('telemetryDataPoints'):
689687
self.__telemetry_dp_rate_limit.set_limit(rate_limits_config.get('telemetryDataPoints'), percentage=80)
690688
if service_config.get('maxInflightMessages'):
691-
self.max_inflight_messages_set(5)#int(service_config.get('maxInflightMessages')))
689+
max_inflight_messages = min(self._messages_rate_limit.get_minimal_limit(),
690+
self.__telemetry_rate_limit.get_minimal_limit(),
691+
service_config.get('maxInflightMessages', 100))
692+
self.max_inflight_messages_set(max_inflight_messages)
692693
if service_config.get('maxPayloadSize'):
693694
self.max_payload_size = int(service_config.get('maxPayloadSize'))
694695
log.info("Service configuration was successfully retrieved and applied.")

tb_gateway_mqtt.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,4 @@ def __on_service_configuration(self, _, response, *args, **kwargs):
346346
# change rate limit for already connected devices
347347
self._change_devices_rate_limit('telemetry_dp_rate_limit',
348348
device_rate_limit_config.get('telemetryDataPoints'))
349-
350-
if service_config.get('maxInflightMessages'):
351-
self.max_inflight_messages_set(int(service_config.get('maxInflightMessages')))
352-
if service_config.get('maxPayloadSize'):
353-
self.max_payload_size = int(service_config.get('maxPayloadSize'))
354-
if service_config.get('payloadType'):
355-
pass
356349
self.rate_limits_received = True

0 commit comments

Comments
 (0)