constrain port in config, catch value error

This commit is contained in:
Timothy Pogue 2022-09-16 19:22:24 -06:00
parent b0b575ead9
commit 4422ac7f45
2 changed files with 10 additions and 1 deletions

View File

@ -497,7 +497,12 @@ CONF_SCHEMA = {
'properties': {
'name': {'type': 'string'},
'host': {'type': 'string'},
'port': {'type': 'integer', 'default': 8080},
'port': {
'type': 'integer',
'default': 8080,
'minimum': 0,
'maximum': 65535
},
'ws_token': {'type': 'string'},
},
'required': ['name', 'host', 'ws_token']

View File

@ -205,6 +205,10 @@ class ExternalMessageConsumer:
# Now receive data, if none is within the time limit, ping
await self._receive_messages(channel, producer, lock)
except (websockets.exceptions.InvalidURI, ValueError) as e:
logger.error(f"{ws_url} is an invalid WebSocket URL - {e}")
break
except (
socket.gaierror,
ConnectionRefusedError,