From 6126925dbe8c125facc3e0898d3091e798a81f97 Mon Sep 17 00:00:00 2001 From: Timothy Pogue Date: Wed, 14 Sep 2022 16:42:14 -0600 Subject: [PATCH] message size limit in mb, default to 8mb --- freqtrade/constants.py | 8 ++++---- freqtrade/rpc/external_message_consumer.py | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 470ffb2a3..371cb9578 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -512,11 +512,11 @@ CONF_SCHEMA = { 'maximum': 1500, 'default': 1500 }, - 'max_message_size': { + 'max_message_size': { # In megabytes 'type': 'integer', - 'minimum': 1048576, # 1mb - 'maxmium': 8388608, # 8.3mb, - 'default': 1048576, # 1mb + 'minimum': 1, + 'maxmium': 20, + 'default': 8, } }, 'required': ['producers'] diff --git a/freqtrade/rpc/external_message_consumer.py b/freqtrade/rpc/external_message_consumer.py index 7dd6c09b0..95031488d 100644 --- a/freqtrade/rpc/external_message_consumer.py +++ b/freqtrade/rpc/external_message_consumer.py @@ -67,8 +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) + # Message size limit, in megabytes. Default 8mb, Use bitwise operator << 20 to convert + # as the websockets client expects bytes. + self.message_size_limit = (self._emc_config.get('message_size_limit', 8) << 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 @@ -177,6 +178,9 @@ class ExternalMessageConsumer: name = producer["name"] ws_url = f"{url}?token={token}" + logger.info( + f"Connecting to {name} @ {url}, max message size: {self.message_size_limit}") + # This will raise InvalidURI if the url is bad async with websockets.connect(ws_url, max_size=self.message_size_limit) as ws: channel = WebSocketChannel(ws, channel_id=name)