message size limit in mb, default to 8mb
This commit is contained in:
parent
aed19ff6ce
commit
6126925dbe
@ -512,11 +512,11 @@ CONF_SCHEMA = {
|
|||||||
'maximum': 1500,
|
'maximum': 1500,
|
||||||
'default': 1500
|
'default': 1500
|
||||||
},
|
},
|
||||||
'max_message_size': {
|
'max_message_size': { # In megabytes
|
||||||
'type': 'integer',
|
'type': 'integer',
|
||||||
'minimum': 1048576, # 1mb
|
'minimum': 1,
|
||||||
'maxmium': 8388608, # 8.3mb,
|
'maxmium': 20,
|
||||||
'default': 1048576, # 1mb
|
'default': 8,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'required': ['producers']
|
'required': ['producers']
|
||||||
|
@ -67,8 +67,9 @@ class ExternalMessageConsumer:
|
|||||||
# The amount of candles per dataframe on the initial request
|
# The amount of candles per dataframe on the initial request
|
||||||
self.initial_candle_limit = self._emc_config.get('initial_candle_limit', 1500)
|
self.initial_candle_limit = self._emc_config.get('initial_candle_limit', 1500)
|
||||||
|
|
||||||
# Message size limit, default 1mb
|
# Message size limit, in megabytes. Default 8mb, Use bitwise operator << 20 to convert
|
||||||
self.message_size_limit = self._emc_config.get('message_size_limit', 2**20)
|
# 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
|
# Setting these explicitly as they probably shouldn't be changed by a user
|
||||||
# Unless we somehow integrate this with the strategy to allow creating
|
# Unless we somehow integrate this with the strategy to allow creating
|
||||||
@ -177,6 +178,9 @@ class ExternalMessageConsumer:
|
|||||||
name = producer["name"]
|
name = producer["name"]
|
||||||
ws_url = f"{url}?token={token}"
|
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
|
# This will raise InvalidURI if the url is bad
|
||||||
async with websockets.connect(ws_url, max_size=self.message_size_limit) as ws:
|
async with websockets.connect(ws_url, max_size=self.message_size_limit) as ws:
|
||||||
channel = WebSocketChannel(ws, channel_id=name)
|
channel = WebSocketChannel(ws, channel_id=name)
|
||||||
|
Loading…
Reference in New Issue
Block a user