Skip to content

Commit 8c2b722

Browse files
committed
another test with check for mqtt port prior start of sattelite
1 parent 4995d42 commit 8c2b722

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

cbpi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "4.7.1.a2"
1+
__version__ = "4.7.1.a3"
22
__codename__ = "Winter Bock"

cbpi/controller/satellite_controller.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from contextlib import AsyncExitStack, asynccontextmanager
55
from re import M
66

7+
import socket
78
import shortuuid
89
import aiomqtt
910
from cbpi import __version__
@@ -43,6 +44,20 @@ def remove_key(self, d, key):
4344
return r
4445

4546
async def init(self):
47+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
48+
closed=True
49+
runs= 4
50+
while closed:
51+
try:
52+
runs-=1
53+
if runs<=0:
54+
logging.error("MQTT Broker not reachable, giving up.")
55+
return
56+
sock.connect((self.host, self.port))
57+
closed=False
58+
except:
59+
logging.warning("MQTT Broker not reachable, retrying ...")
60+
await asyncio.sleep(1)
4661

4762
self.client = aiomqtt.Client(
4863
self.host,

0 commit comments

Comments
 (0)