Add client ZMQ highwater mark and socket connect to local address (BREAKS RUNNING FOR BEGUM)

This commit is contained in:
Hugvey Central Command 2019-05-13 19:51:12 +02:00
parent 019479d916
commit 7b9a5ea335

View file

@ -214,7 +214,7 @@ class VoiceServer(object):
try: try:
address = "tcp://*:{}".format(self.config['voice']['port'] + self.hugvey.id) address = "tcp://*:{}".format(self.config['voice']['port'] + self.hugvey.id)
self.voice_socket = self.ctx.socket(zmq.PUB) self.voice_socket = self.ctx.socket(zmq.PUB)
self.voice_socket.set_hwm(100) self.voice_socket.set_hwm(15)
self.voice_socket.bind(address) self.voice_socket.bind(address)
logger.info( logger.info(
@ -391,14 +391,17 @@ class CommandHandler(object):
def getIp(): def getIp():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# TODO: make it a local ip, eg. 192.168.1.1 # TODO: make it a local ip, eg. 192.168.1.1
s.connect(("185.66.250.60", 80)) s.connect(("192.168.1.1", 80))
return s.getsockname()[0] ip = s.getsockname()[0]
s.close()
return ip
def sendMessage(self, msg): def sendMessage(self, msg):
self.eventQueue.append(msg) self.eventQueue.append(msg)
async def command_listener(self): async def command_listener(self):
s = self.ctx.socket(zmq.SUB) s = self.ctx.socket(zmq.SUB)
s.set_hwm(15)
s.connect(self.cmd_address) s.connect(self.cmd_address)
topic = getTopic(self.hugvey_id) topic = getTopic(self.hugvey_id)
s.subscribe(topic) s.subscribe(topic)
@ -415,6 +418,7 @@ class CommandHandler(object):
async def event_sender(self): async def event_sender(self):
s = self.ctx.socket(zmq.PUB) s = self.ctx.socket(zmq.PUB)
s.set_hwm(15)
s.connect(self.publish_address) s.connect(self.publish_address)
logger.info("Publish on: {}".format(self.publish_address)) logger.info("Publish on: {}".format(self.publish_address))
# For some reason, sending only one message is lost, perhaps due # For some reason, sending only one message is lost, perhaps due