def open(self): # noinspection PyUnresolvedReferences self.listener = self.ctx.socket(zmq.ROUTER) if self.create_listener_monitor: self.listener_monitor = self.listener.get_monitor_socket() # noinspection PyUnresolvedReferences # self.poller.register(self.listener, test.POLLIN) public, secret = self.selfEncKeys self.listener.curve_secretkey = secret self.listener.curve_publickey = public self.listener.curve_server = True self.listener.identity = self.publicKey logger.debug( '{} will bind its listener at {}:{}'.format(self, self.ha[0], self.ha[1])) set_keepalive(self.listener, self.config) set_zmq_internal_queue_size(self.listener, self.queue_size) # Cycle to deal with "Address already in use" in case of immediate stack restart. bound = False bind_retries = 0 while not bound: try: self.listener.bind( '{protocol}://{ip}:{port}'.format(ip=self.ha[0], port=self.ha[1], protocol=ZMQ_NETWORK_PROTOCOL) ) bound = True except zmq.error.ZMQError as zmq_err: bind_retries += 1 if bind_retries == 50: raise zmq_err time.sleep(0.2)
def open(self): # noinspection PyUnresolvedReferences self.listener = self.ctx.socket(zmq.ROUTER) if self.create_listener_monitor: self.listener_monitor = self.listener.get_monitor_socket() # noinspection PyUnresolvedReferences # self.poller.register(self.listener, test.POLLIN) public, secret = self.selfEncKeys self.listener.curve_secretkey = secret self.listener.curve_publickey = public self.listener.curve_server = True self.listener.identity = self.publicKey logger.debug('{} will bind its listener at {}:{}'.format( self, self.ha[0], self.ha[1])) set_keepalive(self.listener, self.config) set_zmq_internal_queue_size(self.listener, self.queue_size) # Cycle to deal with "Address already in use" in case of immediate stack restart. bound = False bind_retries = 0 while not bound: try: self.listener.bind('{protocol}://{ip}:{port}'.format( ip=self.ha[0], port=self.ha[1], protocol=ZMQ_NETWORK_PROTOCOL)) bound = True except zmq.error.ZMQError as zmq_err: bind_retries += 1 if bind_retries == 5: raise zmq_err time.sleep(0.2)
def open(self): # noinspection PyUnresolvedReferences self.listener = self.ctx.socket(zmq.ROUTER) self._client_message_provider.listener = self.listener self.listener.setsockopt(zmq.ROUTER_MANDATORY, 1) self.listener.setsockopt(zmq.ROUTER_HANDOVER, self.config.ROUTER_HANDOVER) if self.create_listener_monitor: self.listener_monitor = self.listener.get_monitor_socket() # noinspection PyUnresolvedReferences # self.poller.register(self.listener, test.POLLIN) public, secret = self.selfEncKeys self.listener.curve_secretkey = secret self.listener.curve_publickey = public self.listener.curve_server = True self.listener.identity = self.publicKey logger.info('{} will bind its listener at {}:{}'.format( self, self.ha[0], self.ha[1])) set_keepalive(self.listener, self.config) set_zmq_internal_queue_size(self.listener, self.queue_size) # Cycle to deal with "Address already in use" in case of immediate stack restart. bound = False sleep_between_bind_retries = 0.2 bind_retry_time = 0 while not bound: try: self.listener.bind('{protocol}://{ip}:{port}'.format( ip=self.ha[0], port=self.ha[1], protocol=ZMQ_NETWORK_PROTOCOL)) bound = True except zmq.error.ZMQError as zmq_err: logger.warning( "{} can not bind to {}:{}. Will try in {} secs.".format( self, self.ha[0], self.ha[1], sleep_between_bind_retries)) bind_retry_time += sleep_between_bind_retries if bind_retry_time > self.config.MAX_WAIT_FOR_BIND_SUCCESS: logger.warning( "{} can not bind to {}:{} for {} secs. Going to restart the service." .format(self, self.ha[0], self.ha[1], self.config.MAX_WAIT_FOR_BIND_SUCCESS)) raise zmq_err time.sleep(sleep_between_bind_retries)
def open(self): # noinspection PyUnresolvedReferences self.listener = self.ctx.socket(zmq.ROUTER) # noinspection PyUnresolvedReferences # self.poller.register(self.listener, test.POLLIN) public, secret = self.selfEncKeys self.listener.curve_secretkey = secret self.listener.curve_publickey = public self.listener.curve_server = True self.listener.identity = self.publicKey logger.debug( '{} will bind its listener at {}:{}'.format(self, self.ha[0], self.ha[1])) set_keepalive(self.listener, self.config) set_zmq_internal_queue_size(self.listener, self.queue_size) self.listener.bind( '{protocol}://{ip}:{port}'.format(ip=self.ha[0], port=self.ha[1], protocol=ZMQ_NETWORK_PROTOCOL) )