From 06350a13cbad4de1780058dde2b145bca3146171 Mon Sep 17 00:00:00 2001 From: Timothy Pogue Date: Tue, 13 Sep 2022 16:39:53 -0600 Subject: [PATCH] support specifying message size in emc config --- freqtrade/constants.py | 6 ++++++ freqtrade/rpc/external_message_consumer.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 2cc2fd115..470ffb2a3 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -511,6 +511,12 @@ CONF_SCHEMA = { 'minimum': 0, 'maximum': 1500, 'default': 1500 + }, + 'max_message_size': { + 'type': 'integer', + 'minimum': 1048576, # 1mb + 'maxmium': 8388608, # 8.3mb, + 'default': 1048576, # 1mb } }, 'required': ['producers'] diff --git a/freqtrade/rpc/external_message_consumer.py b/freqtrade/rpc/external_message_consumer.py index fd6ccfacd..7dd6c09b0 100644 --- a/freqtrade/rpc/external_message_consumer.py +++ b/freqtrade/rpc/external_message_consumer.py @@ -67,6 +67,9 @@ class ExternalMessageConsumer: # The amount of candles per dataframe on the initial request self.initial_candle_limit = self._emc_config.get('initial_candle_limit', 1500) + # Message size limit, default 1mb + self.message_size_limit = self._emc_config.get('message_size_limit', 2**20) + # Setting these explicitly as they probably shouldn't be changed by a user # Unless we somehow integrate this with the strategy to allow creating # callbacks for the messages @@ -175,7 +178,7 @@ class ExternalMessageConsumer: ws_url = f"{url}?token={token}" # This will raise InvalidURI if the url is bad - async with websockets.connect(ws_url) as ws: + async with websockets.connect(ws_url, max_size=self.message_size_limit) as ws: channel = WebSocketChannel(ws, channel_id=name) logger.info(f"Producer connection success - {channel}")