do not send to disconnected remotes; do not receive from disconnected remotes
@@ -552,6 +552,11 @@ class ZStack(NetworkInterface):
if self.handlePingPong(msg, frm, ident):
continue
+
+ if ident not in self.remotesByKeys:
+ logger.warning('{} received message from unknown remote {}'.format(self, ident))
+ continue
+
try:
msg = self.deserializeMsg(msg)
except Exception as e:
@@ -763,13 +768,12 @@ class ZStack(NetworkInterface):
try:
if not serialized:
msg = self.prepare_to_send(msg)
+ if remote.isConnected or msg in self.healthMessages:
+ self.metrics.add_event(self.mt_outgoing_size, len(msg))
logger.trace('{} transmitting message {} to {} by socket {} {}'
.format(self, msg, uid, socket.FD, socket.underlying))
socket.send(msg, flags=zmq.NOBLOCK)
- # socket.send(self.signedMsg(msg), flags=zmq.NOBLOCK)
- if remote.isConnected:
- self.metrics.add_event(self.mt_outgoing_size, len(msg))
- if not remote.isConnected:
+ else:
logger.warning('Remote {} is not connected - message will not be sent immediately.'
'If this problem does not resolve itself - check your firewall settings'.format(uid))
self._stashed_to_disconnected \
