message size limit in mb, default to 8mb

This commit is contained in:
Timothy Pogue
2022-09-14 16:42:14 -06:00
parent aed19ff6ce
commit 6126925dbe
2 changed files with 10 additions and 6 deletions

View File

@@ -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)